diff --git a/esp32/include/ControllerConfiguration.h b/esp32/include/ControllerConfiguration.h index 5de1673..f0b6b8d 100644 --- a/esp32/include/ControllerConfiguration.h +++ b/esp32/include/ControllerConfiguration.h @@ -159,7 +159,7 @@ #define SOLAR_MAX_VOLTAGE_POSSIBLE 100 /**< higher values are treated as not connected sensor */ #define VOLT_MAX_BATT 4.2f #define VOLT_SENSORS_BATT 3.6f /**< Minimum battery voltage for sensor (and pump) usage */ -#define VOLT_MIN_BATT 3.2f /**< Minimum battery voltage for normal operation */ +#define VOLT_MIN_BATT 3.4f /**< Minimum battery voltage for normal operation */ #define LOWVOLT_SLEEP_FACTOR 6 /**< Factor for nightsleep delay, if the battery drops below minimum (@see VOLT_MIN_BATT) */ #define LOWVOLT_SLEEP_MINIMUM 7200 /**< At low voltage sleep at least for 120 minutes (two hours) */ diff --git a/esp32/src/PlantCtrl.cpp b/esp32/src/PlantCtrl.cpp index b1fb49c..cb57ea1 100644 --- a/esp32/src/PlantCtrl.cpp +++ b/esp32/src/PlantCtrl.cpp @@ -54,8 +54,10 @@ void Plant::init(void) { return ((candidate >= 0) && (candidate <= 100)); }); /* Initialize Hardware */ + pinMode(this->mPinPump, OUTPUT); + digitalWrite(this->mPinPump, LOW); ledcSetup(this->mPlantId, PWM_FREQ, PWM_BITS); - ledcAttachPin(mPinPump, this->mPlantId); + ledcAttachPin(this->mPinPump, this->mPlantId); ledcWrite(this->mPlantId, 0); pinMode(this->mPinSensor, INPUT); } diff --git a/esp32/src/main.cpp b/esp32/src/main.cpp index 64102e1..d786987 100644 --- a/esp32/src/main.cpp +++ b/esp32/src/main.cpp @@ -213,7 +213,7 @@ void espDeepSleep(bool afterPump = false) } else { - if (mBatteryVoltage < VOLT_MIN_BATT) + if ( ((int) (mBatteryVoltage * 100)) < ((int) (VOLT_MIN_BATT * 100)) ) { /* use the largest sleeping duration */ if (deepSleepNightTime.get() > deepSleepTime.get()) { @@ -772,6 +772,7 @@ void safeSetup() digitalWrite(OUTPUT_ENABLE_PUMP, LOW); pinMode(OUTPUT_ENABLE_SENSOR, OUTPUT); + digitalWrite(OUTPUT_ENABLE_SENSOR, LOW); #ifdef ANALOG_WATER pinMode(SENSOR_TANK_ANALOG, INPUT); @@ -843,9 +844,11 @@ void safeSetup() sensorCount = sensors.getDS18Count(); delay(50); } + + readOneWireSensors(); mBatteryVoltage = battery.getVoltage(BATTSENSOR_INDEX_BATTERY); - if (mBatteryVoltage >= VOLT_SENSORS_BATT) + if ( ((int) (mBatteryVoltage * 100)) >= ((int) (VOLT_SENSORS_BATT * 100)) ) { /* read all sensors with additional power source */ readPowerSwitchedSensors(); @@ -1102,7 +1105,7 @@ void plantcontrol() } } - if (mBatteryVoltage < VOLT_MIN_BATT) + if ( ((int) (mBatteryVoltage * 100)) < ((int) (VOLT_MIN_BATT * 100)) ) { sensorLipo.setProperty("percent").send("0"); }