mirror of
https://github.com/airgradienthq/arduino.git
synced 2025-07-15 17:52:08 +02:00
Restart device after PMS sensor read failed 10 times
This commit is contained in:
@ -68,7 +68,6 @@ static LocalServer localServer(Serial, openMetrics, measurements, configuration,
|
||||
wifiConnector);
|
||||
static MqttClient mqttClient(Serial);
|
||||
|
||||
static int pmFailCount = 0;
|
||||
static int getCO2FailCount = 0;
|
||||
static AgFirmwareMode fwMode = FW_MODE_I_33PS;
|
||||
|
||||
@ -566,16 +565,21 @@ static void updatePm(void) {
|
||||
Serial.printf("PM2.5 ug/m3: %d\r\n", measurements.pm25_1);
|
||||
Serial.printf("PM10 ug/m3: %d\r\n", measurements.pm10_1);
|
||||
Serial.printf("PM0.3 Count: %d\r\n", measurements.pm03PCount_1);
|
||||
pmFailCount = 0;
|
||||
ag.pms5003.resetFailCount();
|
||||
} else {
|
||||
pmFailCount++;
|
||||
Serial.printf("PMS read failed: %d\r\n", pmFailCount);
|
||||
if (pmFailCount >= 3) {
|
||||
ag.pms5003.updateFailCount();
|
||||
Serial.printf("PMS read failed: %d\r\n", ag.pms5003.getFailCount());
|
||||
if (ag.pms5003.getFailCount() >= PMS_FAIL_COUNT_SET_INVALID) {
|
||||
measurements.pm01_1 = utils::getInvalidPMS();
|
||||
measurements.pm25_1 = utils::getInvalidPMS();
|
||||
measurements.pm10_1 = utils::getInvalidPMS();
|
||||
measurements.pm03PCount_1 = utils::getInvalidPMS();
|
||||
}
|
||||
|
||||
if(ag.pms5003.getFailCount() >= ag.pms5003.getFailCountMax()) {
|
||||
Serial.printf("Restarting...");
|
||||
ESP.restart();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user