@@ -48,11 +48,6 @@ bool isMqttConnected = false;
48
48
bool isPortalActive = false ;
49
49
byte appState = 0 ; // 0 = init; 1 = preheating; 2 = ready
50
50
51
- bool isPreheating = true ;
52
- bool isCo2SensorReady = false ;
53
- int lastTemperature = 0 ;
54
- int lastCo2Value = 0 ;
55
-
56
51
// (old) timers
57
52
unsigned long lastInfoSend = 0 ;
58
53
unsigned long lastCo2Measurement = 0 ;
@@ -153,15 +148,17 @@ void sendInfo()
153
148
network[" wifiSsid" ] = WiFi.SSID ();
154
149
network[" ip" ] = WiFi.localIP ().toString ();
155
150
151
+ bool isReady = co2Sensor.isReady ();
152
+
156
153
// CO2 meter
157
154
JsonObject co2Meter = doc.createNestedObject (" co2" );
158
- co2Meter[" isPreheating" ] = isPreheating ;
159
- co2Meter[" isReady" ] = isCo2SensorReady ;
155
+ co2Meter[" isPreheating" ] = co2Sensor. isPreHeating () ;
156
+ co2Meter[" isReady" ] = isReady ;
160
157
161
- if (isCo2SensorReady )
158
+ if (isReady )
162
159
{
163
- co2Meter[" temperature" ] = lastTemperature ;
164
- co2Meter[" ppm" ] = lastCo2Value ;
160
+ co2Meter[" temperature" ] = co2Sensor. getLastTemperature () ;
161
+ co2Meter[" ppm" ] = co2Sensor. readCO2UART () ;
165
162
}
166
163
167
164
String JS;
@@ -508,8 +505,7 @@ void loop()
508
505
509
506
if (!isPortalActive && !isUpdating)
510
507
{
511
- isPreheating = co2Sensor.isPreHeating ();
512
- isCo2SensorReady = co2Sensor.isReady ();
508
+ bool isPreheating = co2Sensor.isPreHeating ();
513
509
514
510
if (isPreheating)
515
511
{
@@ -532,8 +528,8 @@ void loop()
532
528
533
529
if (lastCo2Measurement == 0 || millis () - lastCo2Measurement >= READ_SENSOR_INTERVAL)
534
530
{
535
- lastTemperature = co2Sensor.getLastTemperature ();
536
- lastCo2Value = co2Sensor.readCO2UART ();
531
+ int lastTemperature = co2Sensor.getLastTemperature ();
532
+ int lastCo2Value = co2Sensor.readCO2UART ();
537
533
538
534
Serial.print (" temperature: " );
539
535
Serial.println (lastTemperature);
0 commit comments