File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change 1212 */
1313
1414#include < Arduino.h>
15+ #include < math.h>
1516#include < DHT.h> // Adafruit's DHT sensor library https://github.com/adafruit/DHT-sensor-library
1617#include < DHT_U.h>
1718#include < DNSServer.h> // Local DNS Server used for redirecting all requests to the configuration portal
@@ -86,7 +87,11 @@ void loop() {
8687
8788 // Compensate for humidity
8889 float humidity = dht.readHumidity ();
90+ if (isnan (humidity)) {
91+ data.error |= H_ERROR_HUMIDITY;
92+ } else {
8993 sensor.humidityCompensation (data, humidity);
94+ }
9095
9196 // Send the data to the hackAIR server
9297 String dataJson = " {\" reading\" :{\" PM2.5_AirPollutantValue\" :\" " ;
@@ -98,7 +103,7 @@ void loop() {
98103 dataJson += " \" ,\" tamper\" :\" " ;
99104 dataJson += " 0" ;
100105 dataJson += " \" ,\" error\" :\" " ;
101- dataJson += " 0 " ;
106+ dataJson += data. error ;
102107 dataJson += " \" }" ;
103108 if (client.connect (" api.hackair.eu" , 443 )) {
104109 Serial.println (" connected" );
You can’t perform that action at this time.
0 commit comments