12
12
// #define ASYNC_WEBSERVER_ON // - EXPERIMENTAL - FOR ESP32 ONLY!
13
13
#endif
14
14
15
-
16
15
/*
17
16
18
17
ESP8266
37
36
SDS011/21: VIN - 5V; GND - G; TX - D1; RX - D2
38
37
Sensirion SPS30: VIN - 5V; GND - G; TX - D1; RX - D2
39
38
39
+
40
40
ESP32
41
41
42
42
Podłączenie czujnikow dla ESP32:
144
144
#endif
145
145
#include < ESP8266mDNS.h>
146
146
#ifndef ASYNC_WEBSERVER_ON
147
-
148
147
#include < ESP8266HTTPUpdateServer.h>
149
148
#endif
150
149
#include < SoftwareSerial.h>
151
150
#elif defined ARDUINO_ARCH_ESP32 // Arduino core for the ESP32 - 1.0.4-rc1 or later // at 1.0.3 autoupdate doesn't work !!!
152
151
#include < WiFi.h>
153
152
#include < WiFiClient.h>
154
153
#include < ESPmDNS.h>
155
-
156
154
#ifdef ASYNC_WEBSERVER_ON
157
155
#include < AsyncTCP.h>
158
156
#include < ESPAsyncWebServer.h>
159
157
#else
160
158
#include < WebServer.h>
161
159
#endif
162
-
163
160
#include < Update.h>
164
161
#include < HTTPClient.h>
165
162
#include < HTTPUpdate.h>
@@ -307,9 +304,7 @@ AsyncWebServer server(80);
307
304
#else
308
305
#ifdef ARDUINO_ARCH_ESP8266
309
306
ESP8266WebServer WebServer (80 );
310
- #ifndef DUSTSENSOR_SPS30
311
307
ESP8266HTTPUpdateServer httpUpdater;
312
- #endif
313
308
#elif defined ARDUINO_ARCH_ESP32
314
309
WebServer WebServer (80 );
315
310
#endif
@@ -522,7 +517,6 @@ void setup() {
522
517
#elif defined DUSTSENSOR_SPS30
523
518
if (!strcmp (DUST_MODEL, " SPS30" )) {
524
519
Serial.println (F (" Trying to connect to SPS30..." ));
525
-
526
520
// set driver debug level
527
521
sps30.EnableDebugging (SPS30_DEBUG);
528
522
@@ -743,9 +737,7 @@ void setup() {
743
737
WebServer.onNotFound (handle_root);
744
738
745
739
#ifdef ARDUINO_ARCH_ESP8266
746
- #ifndef DUSTSENSOR_SPS30
747
740
httpUpdater.setup (&WebServer, " /update" );
748
- #endif
749
741
#elif defined ARDUINO_ARCH_ESP32
750
742
/* handling uploading firmware file */
751
743
WebServer.on (" /update" , HTTP_POST, []() {
@@ -821,7 +813,6 @@ void loop() {
821
813
}
822
814
#endif
823
815
// DUST SENSOR refresh data - END
824
-
825
816
// yield();
826
817
827
818
#ifndef ASYNC_WEBSERVER_ON
@@ -881,7 +872,6 @@ void loop() {
881
872
#ifndef ASYNC_WEBSERVER_ON
882
873
WebServer.handleClient ();
883
874
#endif
884
-
885
875
previous_2sec_Millis = millis ();
886
876
}
887
877
if (LUFTDATEN_ON or AQI_ECO_ON or AIRMONITOR_ON or SMOGLIST_ON) {
@@ -1356,56 +1346,6 @@ void takeNormalnPMMeasurements() {
1356
1346
#elif defined DUSTSENSOR_SPS30
1357
1347
read_sps30_data ();
1358
1348
1359
- pmMeasurements[iPM][0 ] = int (calib * SPS30_PM1);
1360
- pmMeasurements[iPM][1 ] = int (calib * SPS30_PM25);
1361
- pmMeasurements[iPM][2 ] = int (calib * SPS30_PM10);
1362
- pmMeasurements[iPM][3 ] = int (calib * SPS30_PM4);
1363
- #else // If no dust sensor has been defined - use DUSTSENSOR_PMS5003_7003_BME280_0x76
1364
- pmMeasurements[iPM][0 ] = int (calib * data.PM_AE_UG_1_0 );
1365
- pmMeasurements[iPM][1 ] = int (calib * data.PM_AE_UG_2_5 );
1366
- pmMeasurements[iPM][2 ] = int (calib * data.PM_AE_UG_10_0 );
1367
- =======
1368
- pmMeasurements[iPM][0 ] = int (calib * data.PM_AE_UG_1_0 );
1369
- pmMeasurements[iPM][1 ] = int (calib * data.PM_AE_UG_2_5 );
1370
- pmMeasurements[iPM][2 ] = int (calib * data.PM_AE_UG_10_0 );
1371
- #elif defined DUSTSENSOR_SDS011_21
1372
- #ifdef ARDUINO_ARCH_ESP8266
1373
- PmResult SDSdata = sds.queryPm ();
1374
- delay (1000 );
1375
- if (SDSdata.isOk ()) {
1376
- pmMeasurements[iPM][0 ] = int (calib * 0 );
1377
- pmMeasurements[iPM][1 ] = int (calib * SDSdata.pm25 );
1378
- pmMeasurements[iPM][2 ] = int (calib * SDSdata.pm10 );
1379
- } else {
1380
- Serial.println (" \n Could not read values from SDS sensor :( " );
1381
- }
1382
- #elif defined ARDUINO_ARCH_ESP32
1383
- err = my_sds.read (&SDSpm25, &SDSpm10);
1384
- if (!err) {
1385
- pmMeasurements[iPM][0 ] = int (calib * 0 );
1386
- pmMeasurements[iPM][1 ] = int (calib * SDSpm25);
1387
- pmMeasurements[iPM][2 ] = int (calib * SDSpm10);
1388
- } else {
1389
- Serial.println (" \n Could not read values from SDS sensor :( " );
1390
- }
1391
- #endif
1392
- #elif defined DUSTSENSOR_HPMA115S0
1393
- if (hpma115S0.ReadParticleMeasurement (&hpma115S0_pm25, &hpma115S0_pm10)) {
1394
- if (hpma115S0_pm25 == 0 and hpma115S0_pm10 == 0 ) {
1395
- delay (100 );
1396
- hpma115S0.ReadParticleMeasurement (&hpma115S0_pm25, &hpma115S0_pm10);
1397
- pmMeasurements[iPM][0 ] = int (calib * 0 );
1398
- pmMeasurements[iPM][1 ] = int (calib * hpma115S0_pm25);
1399
- pmMeasurements[iPM][2 ] = int (calib * hpma115S0_pm10);
1400
- } else {
1401
- pmMeasurements[iPM][0 ] = int (calib * 0 );
1402
- pmMeasurements[iPM][1 ] = int (calib * hpma115S0_pm25);
1403
- pmMeasurements[iPM][2 ] = int (calib * hpma115S0_pm10);
1404
- }
1405
- }
1406
- #elif defined DUSTSENSOR_SPS30
1407
- read_sps30_data ();
1408
-
1409
1349
pmMeasurements[iPM][0 ] = int (calib * SPS30_PM1);
1410
1350
pmMeasurements[iPM][1 ] = int (calib * SPS30_PM25);
1411
1351
pmMeasurements[iPM][2 ] = int (calib * SPS30_PM10);
@@ -1450,7 +1390,6 @@ void takeSleepPMMeasurements() {
1450
1390
#ifndef ASYNC_WEBSERVER_ON
1451
1391
WebServer.handleClient ();
1452
1392
#endif
1453
-
1454
1393
previous_2sec_Millis = millis ();
1455
1394
}
1456
1395
previous_2sec_Millis = 0 ;
@@ -1466,6 +1405,7 @@ void takeSleepPMMeasurements() {
1466
1405
takeNormalnPMMeasurements ();
1467
1406
counterNM1++;
1468
1407
}
1408
+
1469
1409
previous_2sec_Millis = millis ();
1470
1410
}
1471
1411
#ifndef ASYNC_WEBSERVER_ON
@@ -1544,7 +1484,6 @@ void takeSleepPMMeasurements() {
1544
1484
unsigned long current_2sec_Millis = millis ();
1545
1485
previous_2sec_Millis = millis ();
1546
1486
while (previous_2sec_Millis - current_2sec_Millis <= TwoSec_interval * 8 ) {
1547
-
1548
1487
#ifndef ASYNC_WEBSERVER_ON
1549
1488
WebServer.handleClient ();
1550
1489
#endif
@@ -1564,7 +1503,6 @@ void takeSleepPMMeasurements() {
1564
1503
}
1565
1504
previous_2sec_Millis = millis ();
1566
1505
}
1567
-
1568
1506
#ifndef ASYNC_WEBSERVER_ON
1569
1507
WebServer.handleClient ();
1570
1508
#endif
@@ -1588,7 +1526,6 @@ void takeSleepPMMeasurements() {
1588
1526
unsigned long current_2sec_Millis = millis ();
1589
1527
previous_2sec_Millis = millis ();
1590
1528
while (previous_2sec_Millis - current_2sec_Millis <= TwoSec_interval * 8 ) {
1591
-
1592
1529
#ifndef ASYNC_WEBSERVER_ON
1593
1530
WebServer.handleClient ();
1594
1531
#endif
0 commit comments