@@ -48,11 +48,6 @@ bool isMqttConnected = false;
4848bool isPortalActive = false ;
4949byte appState = 0 ; // 0 = init; 1 = preheating; 2 = ready
5050
51- bool isPreheating = true ;
52- bool isCo2SensorReady = false ;
53- int lastTemperature = 0 ;
54- int lastCo2Value = 0 ;
55-
5651// (old) timers
5752unsigned long lastInfoSend = 0 ;
5853unsigned long lastCo2Measurement = 0 ;
@@ -153,15 +148,17 @@ void sendInfo()
153148 network[" wifiSsid" ] = WiFi.SSID ();
154149 network[" ip" ] = WiFi.localIP ().toString ();
155150
151+ bool isReady = co2Sensor.isReady ();
152+
156153 // CO2 meter
157154 JsonObject co2Meter = doc.createNestedObject (" co2" );
158- co2Meter[" isPreheating" ] = isPreheating ;
159- co2Meter[" isReady" ] = isCo2SensorReady ;
155+ co2Meter[" isPreheating" ] = co2Sensor. isPreHeating () ;
156+ co2Meter[" isReady" ] = isReady ;
160157
161- if (isCo2SensorReady )
158+ if (isReady )
162159 {
163- co2Meter[" temperature" ] = lastTemperature ;
164- co2Meter[" ppm" ] = lastCo2Value ;
160+ co2Meter[" temperature" ] = co2Sensor. getLastTemperature () ;
161+ co2Meter[" ppm" ] = co2Sensor. readCO2UART () ;
165162 }
166163
167164 String JS;
@@ -508,8 +505,7 @@ void loop()
508505
509506 if (!isPortalActive && !isUpdating)
510507 {
511- isPreheating = co2Sensor.isPreHeating ();
512- isCo2SensorReady = co2Sensor.isReady ();
508+ bool isPreheating = co2Sensor.isPreHeating ();
513509
514510 if (isPreheating)
515511 {
@@ -532,8 +528,8 @@ void loop()
532528
533529 if (lastCo2Measurement == 0 || millis () - lastCo2Measurement >= READ_SENSOR_INTERVAL)
534530 {
535- lastTemperature = co2Sensor.getLastTemperature ();
536- lastCo2Value = co2Sensor.readCO2UART ();
531+ int lastTemperature = co2Sensor.getLastTemperature ();
532+ int lastCo2Value = co2Sensor.readCO2UART ();
537533
538534 Serial.print (" temperature: " );
539535 Serial.println (lastTemperature);
0 commit comments