Skip to content

Commit fb5f766

Browse files
committed
Return an error if no values are recorded during readAverageData
1 parent 0214a2c commit fb5f766

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

examples/Wemos/Wemos.ino

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,15 @@ void loop() {
8585
sensor.clearData(data);
8686
sensor.readAverageData(data, 60); // 60 averages
8787

88+
if (data.error != H_ERROR_SENSOR) {
8889
// Compensate for humidity
8990
float humidity = dht.readHumidity();
9091
if (isnan(humidity)) {
9192
data.error |= H_ERROR_HUMIDITY;
9293
} else {
9394
sensor.humidityCompensation(data, humidity);
9495
}
96+
}
9597

9698
// Send the data to the hackAIR server
9799
String dataJson = "{\"reading\":{\"PM2.5_AirPollutantValue\":\"";

src/hackair.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ void hackAIR::readAverageData(hackAirData &data, uint8_t n) {
157157

158158
if (successes != n) {
159159
data.error = H_ERROR_SENSOR_ONCE;
160+
} else if (successes == 0) {
161+
data.error = H_ERROR_SENSOR;
160162
} else {
161163
data.error = H_NO_ERROR;
162164
}

0 commit comments

Comments
 (0)