mirror of
https://github.com/airgradienthq/arduino.git
synced 2025-07-21 12:42:10 +02:00
PMS5003 add failed count to 3 before show invalid value to display
This commit is contained in:
@ -381,6 +381,7 @@ static void showNr(void);
|
||||
bool hasSensorS8 = true;
|
||||
bool hasSensorPMS = true;
|
||||
bool hasSensorSHT = true;
|
||||
int pmFailCount = 0;
|
||||
AgSchedule configSchedule(SERVER_CONFIG_UPDATE_INTERVAL, serverConfigPoll);
|
||||
AgSchedule serverSchedule(SERVER_SYNC_INTERVAL, sendDataToServer);
|
||||
AgSchedule dispSchedule(DISP_UPDATE_INTERVAL, dispHandler);
|
||||
@ -617,9 +618,14 @@ void pmPoll() {
|
||||
if (ag.pms5003.readData()) {
|
||||
pm25 = ag.pms5003.getPm25Ae();
|
||||
Serial.printf("PMS2.5: %d\r\n", pm25);
|
||||
pmFailCount = 0;
|
||||
} else {
|
||||
Seria.printf("PM read failed, %d", pmFailCount);
|
||||
pmFailCount++;
|
||||
if (pmFailCount >= 3) {
|
||||
pm25 = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void tempHumPoll() {
|
||||
|
@ -690,6 +690,7 @@ bool hasSensorS8 = true;
|
||||
bool hasSensorPMS = true;
|
||||
bool hasSensorSGP = true;
|
||||
bool hasSensorSHT = true;
|
||||
int pmFailCount = 0;
|
||||
AgSchedule dispLedSchedule(DISP_UPDATE_INTERVAL, updateDispLedBar);
|
||||
AgSchedule configSchedule(SERVER_CONFIG_UPDATE_INTERVAL, serverConfigPoll);
|
||||
AgSchedule serverSchedule(SERVER_SYNC_INTERVAL, sendDataToServer);
|
||||
@ -1035,7 +1036,7 @@ static void displayShowDashboard(String err) {
|
||||
|
||||
/** Show temperature */
|
||||
if (agServer.isTemperatureUnitF()) {
|
||||
if (temp > -10001) {
|
||||
if (temp > -1001) {
|
||||
float tempF = (temp * 9 / 5) + 32;
|
||||
sprintf(strBuf, "%.1f°F", tempF);
|
||||
} else {
|
||||
@ -1043,7 +1044,7 @@ static void displayShowDashboard(String err) {
|
||||
}
|
||||
u8g2.drawUTF8(1, 10, strBuf);
|
||||
} else {
|
||||
if (temp > -10001) {
|
||||
if (temp > -1001) {
|
||||
sprintf(strBuf, "%.1f°C", temp);
|
||||
} else {
|
||||
sprintf(strBuf, "-°C");
|
||||
@ -1070,7 +1071,7 @@ static void displayShowDashboard(String err) {
|
||||
if (err == "WiFi N/A") {
|
||||
u8g2.setFont(u8g2_font_t0_12_tf);
|
||||
if (agServer.isTemperatureUnitF()) {
|
||||
if (temp > -10001) {
|
||||
if (temp > -1001) {
|
||||
float tempF = (temp * 9 / 5) + 32;
|
||||
sprintf(strBuf, "%.1f", tempF);
|
||||
} else {
|
||||
@ -1078,7 +1079,7 @@ static void displayShowDashboard(String err) {
|
||||
}
|
||||
u8g2.drawUTF8(1, 10, strBuf);
|
||||
} else {
|
||||
if (temp > -10001) {
|
||||
if (temp > -1001) {
|
||||
sprintf(strBuf, "%.1f", temp);
|
||||
} else {
|
||||
sprintf(strBuf, "-");
|
||||
@ -1810,12 +1811,17 @@ static void pmPoll(void) {
|
||||
Serial.printf(" PMS2.5: %d\r\n", pm25);
|
||||
Serial.printf(" PMS10.0: %d\r\n", pm10);
|
||||
Serial.printf("PMS3.0 Count: %d\r\n", pm03PCount);
|
||||
pmFailCount = 0;
|
||||
} else {
|
||||
pmFailCount++;
|
||||
Serial.printf("PM read failed: %d\r\n", pmFailCount);
|
||||
if (pmFailCount >= 3) {
|
||||
pm01 = -1;
|
||||
pm25 = -1;
|
||||
pm10 = -1;
|
||||
pm03PCount = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user