From 61171fb3796ab54259977d5b39bd5300ac005442 Mon Sep 17 00:00:00 2001 From: Ollo Date: Fri, 6 Nov 2020 23:29:46 +0100 Subject: [PATCH] States described in doxygen --- esp32/include/ControllerConfiguration.h | 54 +++++++++++++++++-------- esp32/include/HomieConfiguration.h | 8 +++- esp32/src/main.cpp | 2 +- 3 files changed, 44 insertions(+), 20 deletions(-) diff --git a/esp32/include/ControllerConfiguration.h b/esp32/include/ControllerConfiguration.h index ede953e..2edae32 100644 --- a/esp32/include/ControllerConfiguration.h +++ b/esp32/include/ControllerConfiguration.h @@ -17,6 +17,26 @@ * * @subpage Configuration * + * There are several modes in the controller + * \dot + * digraph Operationmode { + * ranksep=.75; + * poweroff [ label="off" ]; + * mode1 [ label="Mode 1 - Sensor only", shape=box, width=2 ]; + * mode2 [ label="Mode 2 - Wifi enabled", shape=box ]; + * mode3 [ label="Mode 3 - Stay alive", shape=box ]; + * mode1 -> mode2 [ label="wakeup reason", fontsize=10 ]; + * mode1 -> mode2 [ label="Time duration", fontsize=10 ]; + * mode2 -> mode3 [ label="Over the Air Update", fontsize=10 ]; + * mode3 -> mode2 [ label="Over the Air Finished", fontsize=10 ]; + * mode3 -> mode2 [ label="Mqtt Command", fontsize=10 ]; + * mode2 -> mode3 [ label="Mqtt Command", fontsize=10 ]; + * poweroff -> mode1 [ label="deep sleep wakeup", fontsize=10 ]; + * mode1 -> poweroff [ label="enter deep sleep", fontsize=10 ]; + * mode2 -> poweroff [ label="Mqtt queue empty", fontsize=10 ]; + * } + * \enddot + * * @} */ #ifndef CONTROLLER_CONFIG_H @@ -26,10 +46,10 @@ */ #define FIRMWARE_VERSION "1.0.9" -#define ADC_TO_VOLT(adc) ((adc) * 3.3 ) / 4095) -#define ADC_TO_VOLT_WITH_MULTI(adc, multi) (((adc)*3.3 * (multi)) / 4095) -#define MOIST_SENSOR_MAX_ADC 85 * 4095 / 100 -#define MOIST_SENSOR_MIN_ADC 25 * 4095 / 100 +#define ADC_TO_VOLT(adc) ((adc) * 3.3 ) / 4095) +#define ADC_TO_VOLT_WITH_MULTI(adc, multi) (((adc)*3.3 * (multi)) / 4095) +#define MOIST_SENSOR_MAX_ADC (85 * 4095 / 100) +#define MOIST_SENSOR_MIN_ADC (25 * 4095 / 100) #define SOLAR_VOLT(adc) ADC_TO_VOLT_WITH_MULTI(adc, 4.0306) /**< 100k and 33k voltage dividor */ #define ADC_5V_TO_3V3(adc) ADC_TO_VOLT_WITH_MULTI(adc, 1.7) /**< 33k and 47k8 voltage dividor */ @@ -45,27 +65,27 @@ #define SENSOR_PLANT5 14 /**< GPIO 14 (ADC2) */ #define SENSOR_PLANT6 12 /**< GPIO 12 (ADC2) */ -#define OUTPUT_PUMP0 23 /**< GPIO 23 */ -#define OUTPUT_PUMP1 22 /**< GPIO 22 */ +#define OUTPUT_PUMP0 23 /**< GPIO 23 */ +#define OUTPUT_PUMP1 22 /**< GPIO 22 */ #define OUTPUT_PUMP2 21 /**< GPIO 21 */ #define OUTPUT_PUMP3 19 /**< GPIO 19 */ #define OUTPUT_PUMP4 18 /**< GPIO 18 */ -#define OUTPUT_PUMP5 5 /**< GPIO 5 */ +#define OUTPUT_PUMP5 5 /**< GPIO 5 */ #define OUTPUT_PUMP6 15 /**< GPIO 15 */ #define OUTPUT_SENSOR 16 /**< GPIO 16 - Enable Sensors */ -#define OUTPUT_PUMP 13 /**< GPIO 13 - Enable Pumps */ +#define OUTPUT_PUMP 13 /**< GPIO 13 - Enable Pumps */ -#define SENSOR_DS18B20 2 /**< GPIO 2 */ -#define BUTTON 0 /**< GPIO 0 */ +#define SENSOR_DS18B20 2 /**< GPIO 2 - Temperatur sensor */ +#define BUTTON 0 /**< GPIO 0 - Fix button of NodeMCU */ -#define MIN_TIME_RUNNING 5UL /**< Amount of seconds the controller must stay awoken */ -#define MAX_PLANTS 7 -#define MINIMUM_LIPO_VOLT 3.6f /**< Minimum voltage of the Lipo, that must be present */ -#define NO_LIPO_VOLT 2.0f /**< No Lipo connected */ -#define MINIMUM_SOLAR_VOLT 4.0f /**< Minimum voltage of the sun, to detect daylight */ -#define SOLAR_CHARGE_MIN_VOLTAGE 7 -#define SOLAR_CHARGE_MAX_VOLTAGE 9 +#define MIN_TIME_RUNNING 5UL /**< Amount of seconds the controller must stay awoken */ +#define MAX_PLANTS 7 +#define MINIMUM_LIPO_VOLT 3.6f /**< Minimum voltage of the Lipo, that must be present */ +#define NO_LIPO_VOLT 2.0f /**< No Lipo connected */ +#define MINIMUM_SOLAR_VOLT 4.0f /**< Minimum voltage of the sun, to detect daylight */ +#define SOLAR_CHARGE_MIN_VOLTAGE 7 /**< Sun is rising (morning detected) */ +#define SOLAR_CHARGE_MAX_VOLTAGE 9 /**< Sun is shining (noon) */ #define HC_SR04 /**< Ultrasonic distance sensor to measure water level */ #define SENSOR_SR04_ECHO 17 /**< GPIO 17 - Echo */ diff --git a/esp32/include/HomieConfiguration.h b/esp32/include/HomieConfiguration.h index ac4d037..af3070d 100644 --- a/esp32/include/HomieConfiguration.h +++ b/esp32/include/HomieConfiguration.h @@ -36,7 +36,7 @@ HomieNode sensorLipo("lipo", "Battery Status", "Lipo"); HomieNode sensorSolar("solar", "Solar Status", "Solarpanel"); HomieNode sensorWater("water", "WaterSensor", "Water"); HomieNode sensorTemp("temperature", "Temperature", "temperature"); -HomieNode stayAlive("stay", "alive", "alive"); +HomieNode stayAlive("stay", "alive", "alive"); /**< Necessary for Mqtt Active Command */ /* @} */ @@ -72,7 +72,11 @@ HomieSetting ntpServer("ntpServer", "NTP server (pool.ntp.org as d 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 light but not enought to charge battery"); \ HomieSetting mPumpCooldownInHours##plant = HomieSetting("cooldownpump" 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}; + PlantSettings_t mSetting##plant = {&mSensorDry##plant, &mPumpAllowedHourRangeStart##plant, &mPumpAllowedHourRangeEnd##plant, &mPumpOnlyWhenLowLight##plant, &mPumpCooldownInHours##plant}; \ + /**< Generate all settings for one plant + * + * Feature to start pumping only at morning: @link{SOLAR_CHARGE_MIN_VOLTAGE} and @link{SOLAR_CHARGE_MAX_VOLTAGE} + */ /** * @} diff --git a/esp32/src/main.cpp b/esp32/src/main.cpp index afc7944..541e6c5 100644 --- a/esp32/src/main.cpp +++ b/esp32/src/main.cpp @@ -38,7 +38,7 @@ typedef struct } rtc_plant_t; /********************* non volatile enable after deepsleep *******************************/ -RTC_DATA_ATTR rtc_plant_t rtcPlant[7]; +RTC_DATA_ATTR rtc_plant_t rtcPlant[MAX_PLANTS]; RTC_DATA_ATTR long gotoMode2AfterThisTimestamp = 0; RTC_DATA_ATTR long rtcDeepSleepTime = 0; /**< Time, when the microcontroller shall be up again */ RTC_DATA_ATTR int lastPumpRunning = 0;