@@ -30,7 +30,7 @@ extern "C"
3030#define DEVICE_ID (Sprintf(" %06" PRIx64, ESP.getEfuseMac() >> 24 )) // unique device ID
3131#define uS_TO_S_FACTOR 1000000 // Conversion factor for micro seconds to seconds
3232
33- String version = " 1.0.0 " ;
33+ String version = " 1.1.2 " ;
3434
3535AsyncMqttClient mqttClient;
3636
@@ -48,6 +48,9 @@ bool isMqttConnected = false;
4848bool isPortalActive = false ;
4949byte appState = 0 ; // 0 = init; 1 = preheating; 2 = ready
5050
51+ int lastTemperature = 0 ;
52+ int lastCo2Value = 0 ;
53+
5154// (old) timers
5255unsigned long lastInfoSend = 0 ;
5356unsigned long lastCo2Measurement = 0 ;
@@ -152,8 +155,8 @@ void sendInfo()
152155 JsonObject co2Meter = doc.createNestedObject (" co2" );
153156 co2Meter[" isPreheating" ] = co2Sensor.isPreHeating ();
154157 co2Meter[" isReady" ] = co2Sensor.isReady ();
155- co2Meter[" temperature" ] = co2Sensor. getLastTemperature () ;
156- co2Meter[" ppm" ] = co2Sensor. readCO2UART () ;
158+ co2Meter[" temperature" ] = lastTemperature ;
159+ co2Meter[" ppm" ] = lastCo2Value > 0 ? lastCo2Value : 0 ;
157160
158161 String JS;
159162 serializeJson (doc, JS);
@@ -522,8 +525,8 @@ void loop()
522525
523526 if (lastCo2Measurement == 0 || millis () - lastCo2Measurement >= READ_SENSOR_INTERVAL)
524527 {
525- int lastTemperature = co2Sensor.getLastTemperature ();
526- int lastCo2Value = co2Sensor.readCO2UART ();
528+ lastTemperature = co2Sensor.getLastTemperature ();
529+ lastCo2Value = co2Sensor.readCO2UART ();
527530
528531 Serial.print (" temperature: " );
529532 Serial.println (lastTemperature);
0 commit comments