From 195d3d3c1bc394f398244d34b0c1cdb32fd4160e Mon Sep 17 00:00:00 2001 From: Ollo Date: Thu, 25 Aug 2022 18:40:41 +0200 Subject: [PATCH] Ignore voltages above 100V --- esp32/include/ControllerConfiguration.h | 1 + esp32/include/LogDefines.h | 3 ++- esp32/src/main.cpp | 6 +++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/esp32/include/ControllerConfiguration.h b/esp32/include/ControllerConfiguration.h index acf4ddc..268a237 100644 --- a/esp32/include/ControllerConfiguration.h +++ b/esp32/include/ControllerConfiguration.h @@ -110,6 +110,7 @@ #define MAX_PLANTS 7 #define SOLAR_CHARGE_MIN_VOLTAGE 7 /**< Sun is rising (morning detected) */ #define SOLAR_CHARGE_MAX_VOLTAGE 9 /**< Sun is shining (noon) */ +#define SOLAR_MAX_VOLTAGE_POSSIBLE 100 /**< higher values are treated as not connected sensor */ #define VOLT_MAX_BATT 4.2f #define MAX_CONFIG_SETTING_ITEMS 100 /**< Parameter, that can be configured in Homie */ diff --git a/esp32/include/LogDefines.h b/esp32/include/LogDefines.h index dc6ff3c..f007df2 100644 --- a/esp32/include/LogDefines.h +++ b/esp32/include/LogDefines.h @@ -37,4 +37,5 @@ #define LOG_SLEEP_DAY 101 #define LOG_SLEEP_CYCLE 102 #define LOG_MISSING_PUMP -4 -#define LOG_BOOT_ERROR_DETECTION 10000 \ No newline at end of file +#define LOG_BOOT_ERROR_DETECTION 10000 +#define LOG_SOLAR_CHARGER_MISSING 300 \ No newline at end of file diff --git a/esp32/src/main.cpp b/esp32/src/main.cpp index 0df2994..696baab 100644 --- a/esp32/src/main.cpp +++ b/esp32/src/main.cpp @@ -1063,7 +1063,11 @@ void plantcontrol() sensorLipo.setProperty("ICA").send(String(battery.getICA())); sensorLipo.setProperty("DCA").send(String(battery.getDCA())); sensorLipo.setProperty("CCA").send(String(battery.getCCA())); - sensorSolar.setProperty("volt").send(String(mSolarVoltage)); + if (mSolarVoltage < SOLAR_MAX_VOLTAGE_POSSIBLE) { + sensorSolar.setProperty("volt").send(String(mSolarVoltage)); + } else { + log(LOG_LEVEL_INFO, String("Ignore unrealistc sun voltage" + String(mSolarVoltage) +"V"), LOG_SOLAR_CHARGER_MISSING); + } sensorTemp.setProperty(TEMPERATUR_SENSOR_CHIP).send(String(chipTemp)); } else