Controller is starting again
This commit is contained in:
parent
4f7cc70bbd
commit
ff33c58288
@ -11,7 +11,8 @@
|
|||||||
"algorithm": "cpp",
|
"algorithm": "cpp",
|
||||||
"istream": "cpp",
|
"istream": "cpp",
|
||||||
"limits": "cpp",
|
"limits": "cpp",
|
||||||
"streambuf": "cpp"
|
"streambuf": "cpp",
|
||||||
|
"functional": "cpp"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,4 +54,6 @@
|
|||||||
#define SENSOR_SR04_ECHO 17 /**< GPIO 17 - Echo */
|
#define SENSOR_SR04_ECHO 17 /**< GPIO 17 - Echo */
|
||||||
#define SENSOR_SR04_TRIG 23 /**< GPIO 23 - Trigger */
|
#define SENSOR_SR04_TRIG 23 /**< GPIO 23 - Trigger */
|
||||||
|
|
||||||
|
#define MAX_CONFIG_SETTING_ITEMS 30 /**< Parameter, that can be configured in Homie */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -40,6 +40,7 @@ int mWaterAtEmptyLevel = 0;
|
|||||||
int mWaterGone = -1; /**< Amount of centimeter, where no water is seen */
|
int mWaterGone = -1; /**< Amount of centimeter, where no water is seen */
|
||||||
int readCounter = 0;
|
int readCounter = 0;
|
||||||
int mButtonClicks = 0;
|
int mButtonClicks = 0;
|
||||||
|
bool mConfigured = false;
|
||||||
|
|
||||||
RTC_DATA_ATTR int gBootCount = 0;
|
RTC_DATA_ATTR int gBootCount = 0;
|
||||||
|
|
||||||
@ -427,9 +428,16 @@ void setup() {
|
|||||||
WiFi.mode(WIFI_STA);
|
WiFi.mode(WIFI_STA);
|
||||||
|
|
||||||
|
|
||||||
|
if (HomieInternals::MAX_CONFIG_SETTING_SIZE < MAX_CONFIG_SETTING_ITEMS) {
|
||||||
|
Serial << "HOMIE | Settings: " << HomieInternals::MAX_CONFIG_SETTING_SIZE << "/" << MAX_CONFIG_SETTING_ITEMS << endl;
|
||||||
|
Serial << " | Update Limits.hpp : MAX_CONFIG_SETTING_SIZE to " << MAX_CONFIG_SETTING_ITEMS << endl;
|
||||||
|
}
|
||||||
|
|
||||||
Homie_setFirmware("PlantControl", FIRMWARE_VERSION);
|
Homie_setFirmware("PlantControl", FIRMWARE_VERSION);
|
||||||
Homie.setLoopFunction(loopHandler);
|
Homie.setLoopFunction(loopHandler);
|
||||||
|
|
||||||
|
mConfigured = Homie.isConfigured();
|
||||||
|
if (mConfigured) {
|
||||||
// Load the settings
|
// Load the settings
|
||||||
deepSleepTime.setDefaultValue(0);
|
deepSleepTime.setDefaultValue(0);
|
||||||
deepSleepNightTime.setDefaultValue(0);
|
deepSleepNightTime.setDefaultValue(0);
|
||||||
@ -446,15 +454,15 @@ void setup() {
|
|||||||
plant1SensorTrigger.setDefaultValue(0);
|
plant1SensorTrigger.setDefaultValue(0);
|
||||||
plant2SensorTrigger.setDefaultValue(0);
|
plant2SensorTrigger.setDefaultValue(0);
|
||||||
plant3SensorTrigger.setDefaultValue(0);
|
plant3SensorTrigger.setDefaultValue(0);
|
||||||
#if (MAX_PLANTS >= 4)
|
#if (MAX_PLANTS >= 4)
|
||||||
plant4SensorTrigger.setDefaultValue(0);
|
plant4SensorTrigger.setDefaultValue(0);
|
||||||
plant5SensorTrigger.setDefaultValue(0);
|
plant5SensorTrigger.setDefaultValue(0);
|
||||||
plant6SensorTrigger.setDefaultValue(0);
|
plant6SensorTrigger.setDefaultValue(0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HC_SR04
|
#ifdef HC_SR04
|
||||||
waterLevel.setDefaultValue(50);
|
waterLevel.setDefaultValue(50);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Advertise topics
|
// Advertise topics
|
||||||
plant1.advertise("switch").setName("Pump 1")
|
plant1.advertise("switch").setName("Pump 1")
|
||||||
@ -475,7 +483,7 @@ void setup() {
|
|||||||
plant3.advertise("moist").setName("Percent")
|
plant3.advertise("moist").setName("Percent")
|
||||||
.setDatatype("number")
|
.setDatatype("number")
|
||||||
.setUnit("%");
|
.setUnit("%");
|
||||||
#if (MAX_PLANTS >= 4)
|
#if (MAX_PLANTS >= 4)
|
||||||
plant4.advertise("moist").setName("Percent")
|
plant4.advertise("moist").setName("Percent")
|
||||||
.setDatatype("number")
|
.setDatatype("number")
|
||||||
.setUnit("%");
|
.setUnit("%");
|
||||||
@ -489,7 +497,7 @@ void setup() {
|
|||||||
.setDatatype("number")
|
.setDatatype("number")
|
||||||
.setUnit("%");
|
.setUnit("%");
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
sensorTemp.advertise("control")
|
sensorTemp.advertise("control")
|
||||||
.setName("Temperature")
|
.setName("Temperature")
|
||||||
.setDatatype("number")
|
.setDatatype("number")
|
||||||
@ -517,6 +525,7 @@ void setup() {
|
|||||||
.setDatatype("number")
|
.setDatatype("number")
|
||||||
.setUnit("V");
|
.setUnit("V");
|
||||||
sensorWater.advertise("remaining").setDatatype("number").setUnit("%");
|
sensorWater.advertise("remaining").setDatatype("number").setUnit("%");
|
||||||
|
}
|
||||||
|
|
||||||
Homie.setup();
|
Homie.setup();
|
||||||
|
|
||||||
@ -536,18 +545,18 @@ void setup() {
|
|||||||
|
|
||||||
|
|
||||||
// Configure Deep Sleep:
|
// Configure Deep Sleep:
|
||||||
if ((deepSleepNightTime.get() > 0) &&
|
if (mConfigured && (deepSleepNightTime.get() > 0) &&
|
||||||
( SOLAR_VOLT(solarSensor) < MINIMUM_SOLAR_VOLT)) {
|
( SOLAR_VOLT(solarSensor) < MINIMUM_SOLAR_VOLT)) {
|
||||||
Serial << "HOMIE | Setup sleeping for " << deepSleepNightTime.get() << " ms as sun is at " << SOLAR_VOLT(solarSensor) << "V" << endl;
|
Serial << "HOMIE | Setup sleeping for " << deepSleepNightTime.get() << " ms as sun is at " << SOLAR_VOLT(solarSensor) << "V" << endl;
|
||||||
uint64_t usSleepTime = deepSleepNightTime.get() * 1000U;
|
uint64_t usSleepTime = deepSleepNightTime.get() * 1000U;
|
||||||
esp_sleep_enable_timer_wakeup(usSleepTime);
|
esp_sleep_enable_timer_wakeup(usSleepTime);
|
||||||
}else if (deepSleepTime.get()) {
|
}else if (mConfigured && deepSleepTime.get()) {
|
||||||
Serial << "HOMIE | Setup sleeping for " << deepSleepTime.get() << " ms" << endl;
|
Serial << "HOMIE | Setup sleeping for " << deepSleepTime.get() << " ms" << endl;
|
||||||
uint64_t usSleepTime = deepSleepTime.get() * 1000U;
|
uint64_t usSleepTime = deepSleepTime.get() * 1000U;
|
||||||
esp_sleep_enable_timer_wakeup(usSleepTime);
|
esp_sleep_enable_timer_wakeup(usSleepTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (ADC_5V_TO_3V3(lipoSenor) < MINIMUM_LIPO_VOLT) && (deepSleepTime.get()) ) {
|
if (mConfigured && (ADC_5V_TO_3V3(lipoSenor) < MINIMUM_LIPO_VOLT) && (deepSleepTime.get()) ) {
|
||||||
long sleepEmptyLipo = (deepSleepTime.get() * EMPTY_LIPO_MULTIPL);
|
long sleepEmptyLipo = (deepSleepTime.get() * EMPTY_LIPO_MULTIPL);
|
||||||
Serial << "HOMIE | Change sleeping to " << sleepEmptyLipo << " ms as lipo is at " << ADC_5V_TO_3V3(lipoSenor) << "V" << endl;
|
Serial << "HOMIE | Change sleeping to " << sleepEmptyLipo << " ms as lipo is at " << ADC_5V_TO_3V3(lipoSenor) << "V" << endl;
|
||||||
esp_sleep_enable_timer_wakeup(sleepEmptyLipo * 1000U);
|
esp_sleep_enable_timer_wakeup(sleepEmptyLipo * 1000U);
|
||||||
@ -559,7 +568,7 @@ void setup() {
|
|||||||
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_FAST_MEM, ESP_PD_OPTION_OFF);
|
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_FAST_MEM, ESP_PD_OPTION_OFF);
|
||||||
esp_sleep_pd_config(ESP_PD_DOMAIN_XTAL,ESP_PD_OPTION_ON);
|
esp_sleep_pd_config(ESP_PD_DOMAIN_XTAL,ESP_PD_OPTION_ON);
|
||||||
|
|
||||||
|
Serial << "DS18B20 | Initialization " << endl;
|
||||||
/* Read the temperature sensors once, as first time 85 degree is returned */
|
/* Read the temperature sensors once, as first time 85 degree is returned */
|
||||||
Serial << "DS18B20 | sensors: " << String(dallas.readDevices()) << endl;
|
Serial << "DS18B20 | sensors: " << String(dallas.readDevices()) << endl;
|
||||||
delay(200);
|
delay(200);
|
||||||
@ -579,7 +588,7 @@ void setup() {
|
|||||||
* Executs the Homie base functionallity or triggers sleeping, if requested.
|
* Executs the Homie base functionallity or triggers sleeping, if requested.
|
||||||
*/
|
*/
|
||||||
void loop() {
|
void loop() {
|
||||||
if (!mDeepSleep) {
|
if (!mDeepSleep || !mConfigured) {
|
||||||
if (Serial.available() > 0) {
|
if (Serial.available() > 0) {
|
||||||
// read the incoming byte:
|
// read the incoming byte:
|
||||||
int incomingByte = Serial.read();
|
int incomingByte = Serial.read();
|
||||||
|
Loading…
Reference in New Issue
Block a user