From c6ddfea44b2b6816f1e71bf051fd836eca2f7444 Mon Sep 17 00:00:00 2001 From: Ollo Date: Sun, 11 Jun 2023 13:28:52 +0200 Subject: [PATCH 1/2] Handle unrealistic water values --- esp32/include/ControllerConfiguration.h | 2 +- esp32/include/LogDefines.h | 3 +++ esp32/src/main.cpp | 4 ++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/esp32/include/ControllerConfiguration.h b/esp32/include/ControllerConfiguration.h index d39d940..b0b1d92 100644 --- a/esp32/include/ControllerConfiguration.h +++ b/esp32/include/ControllerConfiguration.h @@ -80,7 +80,7 @@ /** \addtogroup Configuration * @{ */ -#define FIRMWARE_VERSION "2.7 HW0.10b" +#define FIRMWARE_VERSION "2.71 HW0.10b" #define TIMED_LIGHT_PIN CUSTOM1_PIN5 #define FLOWMETER_PIN CUSTOM1_PIN1 diff --git a/esp32/include/LogDefines.h b/esp32/include/LogDefines.h index 78285f5..1873ec6 100644 --- a/esp32/include/LogDefines.h +++ b/esp32/include/LogDefines.h @@ -33,6 +33,9 @@ #define LOG_VERY_COLD_WATER "Water potentially frozen, ignoring pump request" #define LOG_VERY_COLD_WATER_CODE -7 +#define LOG_PUMP_FULLTANK_MESSAGE "Water Sensor distance unrealistic" +#define LOG_PUMP_FULLTANK_CODE 3 + //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 12f59bd..c2e5afc 100644 --- a/esp32/src/main.cpp +++ b/esp32/src/main.cpp @@ -1142,6 +1142,10 @@ bool isLowLight = (mSolarVoltage <= SOLAR_CHARGE_MAX_VOLTAGE); { //surface of water is still nearer the sensor than required to cover the pumps hasWater = waterRawSensor.getAverage() < waterLevelMin.get(); + if (waterRawSensor.getAverage() > waterLevelMax.get()) { + log(LOG_LEVEL_ERROR, LOG_PUMP_FULLTANK_MESSAGE, LOG_PUMP_FULLTANK_CODE); + hasWater = true; + } } // FIXME no water warning message From 2636e2defa693d8100c342d1723bed7948e355ab Mon Sep 17 00:00:00 2001 From: Ollo Date: Sun, 11 Jun 2023 13:51:13 +0200 Subject: [PATCH 2/2] Read more distances --- esp32/include/ControllerConfiguration.h | 2 +- esp32/src/main.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/esp32/include/ControllerConfiguration.h b/esp32/include/ControllerConfiguration.h index b0b1d92..c1c0f48 100644 --- a/esp32/include/ControllerConfiguration.h +++ b/esp32/include/ControllerConfiguration.h @@ -115,7 +115,7 @@ #define TEMPERATUR_TIMEOUT 3000 /**< 3 Seconds timeout for the temperatures sensors */ #define WATERSENSOR_TIMEOUT 3000 /**< 3 Seconds timeout for the water distance sensor */ -#define WATERSENSOR_CYCLE 5 /**< 5 sensor measurement are performed */ +#define WATERSENSOR_CYCLE 10 /**< 5 sensor measurement are performed */ #define DS18B20_RESOLUTION 9 /**< 9bit temperature resolution -> 0.5°C steps */ #define UTC_OFFSET_DE 3600 /* UTC offset in seconds for Germany */ diff --git a/esp32/src/main.cpp b/esp32/src/main.cpp index c2e5afc..b97f17e 100644 --- a/esp32/src/main.cpp +++ b/esp32/src/main.cpp @@ -51,7 +51,7 @@ extern "C" bool verifyRollbackLater(){ * DEFINES ******************************************************************************/ #define AMOUNT_SENOR_QUERYS 8 -#define MAX_TANK_DEPTH 2000 +#define MAX_TANK_DEPTH 5000 #define REBOOT_LOOP_DETECTION_ERROR 5 /****************************************************************************** @@ -85,7 +85,7 @@ int volatile selfTestPumpRun = -1; /** pump to run at the end of the cycle */ bool mConfigured = false; long nextBlink = 0; /**< Time needed in main loop to support expected blink code */ -RunningMedian waterRawSensor = RunningMedian(5); +RunningMedian waterRawSensor = RunningMedian(WATERSENSOR_CYCLE); float mSolarVoltage = 0.0f; /**< Voltage from solar panels */ float mBatteryVoltage = 0.0f; /**< Voltage from lipo */ unsigned long setupFinishedTimestamp;