From 37a08dede6f2835766456a28d14deeb58cae46aa Mon Sep 17 00:00:00 2001 From: Empire Date: Tue, 20 Dec 2022 00:04:57 +0100 Subject: [PATCH] add frozen water mode --- esp32/include/LogDefines.h | 3 +++ esp32/src/main.cpp | 25 +++++++++++++++++-------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/esp32/include/LogDefines.h b/esp32/include/LogDefines.h index dc6ff3c..4d3b894 100644 --- a/esp32/include/LogDefines.h +++ b/esp32/include/LogDefines.h @@ -29,6 +29,9 @@ #define LOG_PUMP_AND_DOWNLOADMODE "Download mode, ignoring pump request" #define LOG_PUMP_AND_DOWNLOADMODE_CODE 2 +#define LOG_VERY_COLD_WATER "Water potentially frozen, ignoring pump request" +#define LOG_VERY_COLD_WATER -7 + //msg is dynamic defined #define LOG_PUMP_INEFFECTIVE -4 #define LOG_PUMP_STARTED_CODE 10 diff --git a/esp32/src/main.cpp b/esp32/src/main.cpp index 369cbc5..c9d6ead 100644 --- a/esp32/src/main.cpp +++ b/esp32/src/main.cpp @@ -90,6 +90,8 @@ long lastSendPumpUpdate = 0; long pumpTargetMl = -1; #endif +float waterTemp = 30; + /*************************** Hardware abstraction *****************************/ OneWire oneWire(SENSOR_ONEWIRE); @@ -267,6 +269,7 @@ void readOneWireSensors() { mqttWrite(&sensorTemp, TEMPERATUR_SENSOR_WATER, String(temp)); Serial << "Water Temperatur " << temp << " °C " << endl; + waterTemp = temp; } /* Always send the sensor address with the temperatur value */ mqttWrite(&sensorTemp, String(buf), String(temp)); @@ -1085,25 +1088,31 @@ void plantcontrol() } #endif // TIMED_LIGHT_PIN - + bool isLiquid = waterTemp > 5; bool hasWater = true; // FIXME remaining > waterLevelMin.get(); // FIXME no water warning message pumpToRun = determineNextPump(isLowLight); // early aborts if (pumpToRun != -1) { - if (hasWater) - { - if (mDownloadMode) + if(isLiquid){ + if (hasWater) { - log(LOG_LEVEL_INFO, LOG_PUMP_AND_DOWNLOADMODE, LOG_PUMP_AND_DOWNLOADMODE_CODE); + if (mDownloadMode) + { + log(LOG_LEVEL_INFO, LOG_PUMP_AND_DOWNLOADMODE, LOG_PUMP_AND_DOWNLOADMODE_CODE); + pumpToRun = -1; + } + } + else + { + log(LOG_LEVEL_ERROR, LOG_PUMP_BUTNOTANK_MESSAGE, LOG_PUMP_BUTNOTANK_CODE); pumpToRun = -1; } } - else - { + else{ log(LOG_LEVEL_ERROR, LOG_PUMP_BUTNOTANK_MESSAGE, LOG_PUMP_BUTNOTANK_CODE); - pumpToRun = -1; + pumpToRun = -1; } }