File tree 2 files changed +10
-4
lines changed
2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change 1
1
#define SCREEN_WIDTH 128 // OLED display width, in pixels
2
2
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
3
3
4
+ #define READ_SENSOR_INTERVAL 60000 // in ms
5
+ #define MQTT_UPDATE_INTERVAL 45000 // in ms
4
6
#define PASSWORD "waaatering"
5
7
6
8
int CO2_WARN_PPM = 1200 ;
Original file line number Diff line number Diff line change @@ -149,8 +149,12 @@ void sendInfo()
149
149
JsonObject co2Meter = doc.createNestedObject (" co2" );
150
150
co2Meter[" isPreheating" ] = isPreheating;
151
151
co2Meter[" isReady" ] = isCo2SensorReady;
152
- co2Meter[" temperature" ] = lastTemperature;
153
- co2Meter[" ppm" ] = lastCo2Value;
152
+
153
+ if (isCo2SensorReady)
154
+ {
155
+ co2Meter[" temperature" ] = lastTemperature;
156
+ co2Meter[" ppm" ] = lastCo2Value;
157
+ }
154
158
155
159
String JS;
156
160
serializeJson (doc, JS);
@@ -511,7 +515,7 @@ void loop()
511
515
{
512
516
appState = 2 ;
513
517
514
- if (lastCo2Measurement == 0 || millis () - lastCo2Measurement >= 60000 ) // every minute
518
+ if (lastCo2Measurement == 0 || millis () - lastCo2Measurement >= READ_SENSOR_INTERVAL)
515
519
{
516
520
lastTemperature = co2Sensor.getLastTemperature ();
517
521
lastCo2Value = co2Sensor.readCO2UART ();
@@ -546,7 +550,7 @@ void loop()
546
550
547
551
if (isWifiConnected && isMqttConnected)
548
552
{
549
- if (lastInfoSend == 0 || millis () - lastInfoSend >= 45000 ) // every 45 seconds
553
+ if (lastInfoSend == 0 || millis () - lastInfoSend >= MQTT_UPDATE_INTERVAL)
550
554
{
551
555
sendInfo (); // TODO move to async timer
552
556
}
You can’t perform that action at this time.
0 commit comments