File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed
Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change 11#define SCREEN_WIDTH 128 // OLED display width, in pixels
22#define SCREEN_HEIGHT 64 // OLED display height, in pixels
33
4+ #define READ_SENSOR_INTERVAL 60000 // in ms
5+ #define MQTT_UPDATE_INTERVAL 45000 // in ms
46#define PASSWORD "waaatering"
57
68int CO2_WARN_PPM = 1200 ;
Original file line number Diff line number Diff line change @@ -149,8 +149,12 @@ void sendInfo()
149149 JsonObject co2Meter = doc.createNestedObject (" co2" );
150150 co2Meter[" isPreheating" ] = isPreheating;
151151 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+ }
154158
155159 String JS;
156160 serializeJson (doc, JS);
@@ -511,7 +515,7 @@ void loop()
511515 {
512516 appState = 2 ;
513517
514- if (lastCo2Measurement == 0 || millis () - lastCo2Measurement >= 60000 ) // every minute
518+ if (lastCo2Measurement == 0 || millis () - lastCo2Measurement >= READ_SENSOR_INTERVAL)
515519 {
516520 lastTemperature = co2Sensor.getLastTemperature ();
517521 lastCo2Value = co2Sensor.readCO2UART ();
@@ -546,7 +550,7 @@ void loop()
546550
547551 if (isWifiConnected && isMqttConnected)
548552 {
549- if (lastInfoSend == 0 || millis () - lastInfoSend >= 45000 ) // every 45 seconds
553+ if (lastInfoSend == 0 || millis () - lastInfoSend >= MQTT_UPDATE_INTERVAL)
550554 {
551555 sendInfo (); // TODO move to async timer
552556 }
You can’t perform that action at this time.
0 commit comments