Browse Source

dont show old mqtt values

ir
Hendrik Langer 5 years ago
parent
commit
e7efd1f249
  1. 20
      src/main.cpp

20
src/main.cpp

@ -67,6 +67,7 @@ struct __attribute__((packed)) sensor_readings_t {
float uvb = NAN; float uvb = NAN;
float temperature_max = NAN; // °C float temperature_max = NAN; // °C
float temperature_min = NAN; // °C float temperature_min = NAN; // °C
uint32_t lastUpdate = 0;
} sensor_readings; } sensor_readings;
sensor_readings_t sensors_a4cf1211c3e4, sensors_246f28d1fa5c, sensors_246f28d1a080, sensors_30aea47b0568; sensor_readings_t sensors_a4cf1211c3e4, sensors_246f28d1fa5c, sensors_246f28d1a080, sensors_30aea47b0568;
@ -176,6 +177,8 @@ void getSensorMeasurements() {
sensor_readings.pm25 = pm.pm25; sensor_readings.pm25 = pm.pm25;
} }
} }
sensor_readings.lastUpdate = millis();
} }
@ -214,6 +217,7 @@ void receiveMqtt(const char* topic, const char* data) {
} else if (strcmp("/voc", topic_last) == 0) { } else if (strcmp("/voc", topic_last) == 0) {
sensor->voc = atof(data); sensor->voc = atof(data);
} }
sensor->lastUpdate = millis();
} }
} }
@ -373,10 +377,18 @@ void displayValues() {
// other nodes // other nodes
display.setFont(NULL); display.setFont(NULL);
display.setCursor(0, y_offset+70); display.setCursor(0, y_offset+70);
if (!ota.getMAC().equals("246f28d1fa5c")) display.printf("246f28d1fa5c: %4.1f %4.1f %6.1f\n", sensors_246f28d1fa5c.temperature, sensors_246f28d1fa5c.humidity, sensors_246f28d1fa5c.pressure); if (!ota.getMAC().equals("246f28d1fa5c") && millis() - sensors_246f28d1fa5c.lastUpdate < 15*60*1000) {
if (!ota.getMAC().equals("a4cf1211c3e4")) display.printf("a4cf1211c3e4: %4.1f %4.1f %6.1f\n", sensors_a4cf1211c3e4.temperature, sensors_a4cf1211c3e4.humidity, sensors_a4cf1211c3e4.pressure); display.printf("246f28d1fa5c: %4.1f %4.1f %6.1f\n", sensors_246f28d1fa5c.temperature, sensors_246f28d1fa5c.humidity, sensors_246f28d1fa5c.pressure);
if (!ota.getMAC().equals("246f28d1a080")) display.printf("246f28d1a080: %4.1f %4.1f %6.1f\n", sensors_246f28d1a080.temperature, sensors_246f28d1a080.humidity, sensors_246f28d1a080.pressure); }
if (!ota.getMAC().equals("30aea47b0568")) display.printf("30aea47b0568: %4.1f %4.1f %6.1f\n", sensors_30aea47b0568.temperature, sensors_30aea47b0568.humidity, sensors_30aea47b0568.pressure); if (!ota.getMAC().equals("a4cf1211c3e4") && millis() - sensors_a4cf1211c3e4.lastUpdate < 15*60*1000) {
display.printf("a4cf1211c3e4: %4.1f %4.1f %6.1f\n", sensors_a4cf1211c3e4.temperature, sensors_a4cf1211c3e4.humidity, sensors_a4cf1211c3e4.pressure);
}
if (!ota.getMAC().equals("246f28d1a080") && millis() - sensors_246f28d1a080.lastUpdate < 15*60*1000) {
display.printf("246f28d1a080: %4.1f %4.1f %6.1f\n", sensors_246f28d1a080.temperature, sensors_246f28d1a080.humidity, sensors_246f28d1a080.pressure);
}
if (!ota.getMAC().equals("30aea47b0568") && millis() - sensors_30aea47b0568.lastUpdate < 15*60*1000) {
display.printf("30aea47b0568: %4.1f %4.1f %6.1f\n", sensors_30aea47b0568.temperature, sensors_30aea47b0568.humidity, sensors_30aea47b0568.pressure);
}
} }
while (display.nextPage()); while (display.nextPage());

Loading…
Cancel
Save