From a1de9ee2b91d4143e12d2411751be6a421b1777d Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 29 Jun 2021 23:49:48 +0200 Subject: [PATCH] config reduced, config json parser memory adjusted --- esp32/include/ControllerConfiguration.h | 5 +++-- esp32/include/HomieConfiguration.h | 26 ++++++++++++------------- esp32/src/PlantCtrl.cpp | 3 --- esp32/src/main.cpp | 10 ++++++++-- 4 files changed, 24 insertions(+), 20 deletions(-) diff --git a/esp32/include/ControllerConfiguration.h b/esp32/include/ControllerConfiguration.h index 61f2cf3..2b5ef6f 100644 --- a/esp32/include/ControllerConfiguration.h +++ b/esp32/include/ControllerConfiguration.h @@ -78,7 +78,7 @@ /** \addtogroup Configuration * @{ */ -#define FIRMWARE_VERSION "sw 1.2 hw 0.9" +#define FIRMWARE_VERSION "sw 1.3 hw 0.10" #define MOIST_SENSOR_MAX_ADC (85 * 4095 / 100) #define MOIST_SENSOR_MIN_ADC (25 * 4095 / 100) @@ -94,7 +94,8 @@ #define SOLAR_CHARGE_MAX_VOLTAGE 9 /**< Sun is shining (noon) */ #define VOLT_MAX_BATT 4.2f -#define MAX_CONFIG_SETTING_ITEMS 50 /**< Parameter, that can be configured in Homie */ +#define MAX_CONFIG_SETTING_ITEMS 100 /**< Parameter, that can be configured in Homie */ +#define MAX_JSON_CONFIG_FILE_SIZE_CUSTOM 2500 #define TEMPERATUR_TIMEOUT 3000 /**< 3 Seconds timeout for the temperatur sensors */ #define DS18B20_RESOLUTION 9 /**< 9bit temperature resolution -> 0.5°C steps */ diff --git a/esp32/include/HomieConfiguration.h b/esp32/include/HomieConfiguration.h index f8fc4e2..704295d 100644 --- a/esp32/include/HomieConfiguration.h +++ b/esp32/include/HomieConfiguration.h @@ -65,16 +65,16 @@ HomieNode stayAlive("stay", "alive", "alive"); /**< Necessary for Mqtt Active C * General settings for the controller * @{ */ -HomieSetting deepSleepTime("deepsleep", "time in seconds to sleep"); +HomieSetting deepSleepTime("sleep", "time in seconds to sleep"); HomieSetting deepSleepNightTime("nightsleep", "time in seconds to sleep (0 uses same setting: deepsleep at night, too)"); -HomieSetting wateringDeepSleep("pumpdeepsleep", "time seconds to sleep, while a pump is running"); +HomieSetting wateringDeepSleep("pumpsleep", "time seconds to sleep, while a pump is running"); -HomieSetting waterLevelMax("watermaxlevel", "distance (mm) at maximum water level"); -HomieSetting waterLevelMin("waterminlevel", "distance (mm) at minimum water level (pumps still covered)"); -HomieSetting waterLevelWarn("waterlevelwarn", "warn (mm) if below this water level %"); -HomieSetting waterLevelVol("waterVolume", "(ml) between minimum and maximum"); -HomieSetting lipoSensorAddr("lipoTempAddr", "1wire address for lipo temperature sensor"); -HomieSetting waterSensorAddr("waterTempIndex", "1wire address for water temperature sensor"); +HomieSetting waterLevelMax("tankmax", "distance (mm) at maximum water level"); +HomieSetting waterLevelMin("tankmin", "distance (mm) at minimum water level (pumps still covered)"); +HomieSetting waterLevelWarn("tankwarn", "warn (mm) if below this water level %"); +HomieSetting waterLevelVol("tankVolume", "(ml) between minimum and maximum"); +HomieSetting lipoSensorAddr("lipoDSAddr", "1wire address for lipo temperature sensor"); +HomieSetting waterSensorAddr("tankDSAddr", "1wire address for water temperature sensor"); HomieSetting ntpServer("ntpServer", "NTP server (pool.ntp.org as default)"); /** @@ -88,11 +88,11 @@ HomieSetting ntpServer("ntpServer", "NTP server (pool.ntp.org as d **/ #define GENERATE_PLANT(plant, strplant) \ - HomieSetting mSensorDry##plant = HomieSetting("moistdry" strplant, "Plant " strplant "- Moist sensor dry threshold"); \ - HomieSetting mPumpAllowedHourRangeStart##plant = HomieSetting("rangehourstart" strplant, "Plant" strplant " - Range pump allowed hour start (0-23)"); \ - HomieSetting mPumpAllowedHourRangeEnd##plant = HomieSetting("rangehourend" strplant, "Plant" strplant " - Range pump allowed hour end (0-23)"); \ - HomieSetting mPumpOnlyWhenLowLight##plant = HomieSetting("onlyWhenLowLightZ" strplant, "Plant" strplant " - Enable the Pump only, when there is no sunlight"); \ - HomieSetting mPumpCooldownInHours##plant = HomieSetting("cooldownpump" strplant, "Plant" strplant " - How long to wait until the pump is activated again (minutes)"); \ + HomieSetting mSensorDry##plant = HomieSetting("dry" strplant, "Plant " strplant "- Moist sensor dry threshold"); \ + HomieSetting mPumpAllowedHourRangeStart##plant = HomieSetting("hourstart" strplant, "Plant" strplant " - Range pump allowed hour start (0-23)"); \ + HomieSetting mPumpAllowedHourRangeEnd##plant = HomieSetting("hourend" strplant, "Plant" strplant " - Range pump allowed hour end (0-23)"); \ + HomieSetting mPumpOnlyWhenLowLight##plant = HomieSetting("lowLight" strplant, "Plant" strplant " - Enable the Pump only, when there is no sunlight"); \ + HomieSetting mPumpCooldownInHours##plant = HomieSetting("delay" strplant, "Plant" strplant " - How long to wait until the pump is activated again (minutes)"); \ PlantSettings_t mSetting##plant = {&mSensorDry##plant, &mPumpAllowedHourRangeStart##plant, &mPumpAllowedHourRangeEnd##plant, &mPumpOnlyWhenLowLight##plant, &mPumpCooldownInHours##plant}; \ /**< Generate all settings for one plant \ * \ diff --git a/esp32/src/PlantCtrl.cpp b/esp32/src/PlantCtrl.cpp index d5999d1..9eda6ed 100644 --- a/esp32/src/PlantCtrl.cpp +++ b/esp32/src/PlantCtrl.cpp @@ -60,9 +60,6 @@ void Plant::addSenseValue(void) int raw = analogRead(this->mPinSensor); if(raw < MOIST_SENSOR_MAX_ADC && raw > MOIST_SENSOR_MIN_ADC){ this->moistureRaw.add(raw); - } else { - int plantId = this->mPlantId; - Serial << "ignoring sensor " << plantId << " value due to being strange " << raw << endl; } } diff --git a/esp32/src/main.cpp b/esp32/src/main.cpp index e27d85d..0a59859 100644 --- a/esp32/src/main.cpp +++ b/esp32/src/main.cpp @@ -548,10 +548,17 @@ void setup() if (HomieInternals::MAX_CONFIG_SETTING_SIZE < MAX_CONFIG_SETTING_ITEMS) { - //increase the config settings to 50 and the json to 3000 + //increase the config settings Serial << "Limits.hpp is not adjusted, please search for this string and increase" << endl; return; } + if (HomieInternals::MAX_JSON_CONFIG_FILE_SIZE < MAX_JSON_CONFIG_FILE_SIZE_CUSTOM) + { + //increase the config settings + Serial << "Limits.hpp is not adjusted, please search for this string and increase" << endl; + return; + } + /************************* Start One-Wire bus ***************/ int tempInitStartTime = millis(); @@ -607,7 +614,6 @@ void setup() mConfigured = Homie.isConfigured(); if (mConfigured) { - for (int i = 0; i < MAX_PLANTS; i++) { mPlants[i].advertise();