Deep sleep is now working

This commit is contained in:
c3ma 2020-10-21 18:33:38 +02:00
parent 73759eec68
commit 03be8a1bda
2 changed files with 8 additions and 9 deletions

View File

@ -59,4 +59,6 @@
#define MAX_CONFIG_SETTING_ITEMS 50 /**< Parameter, that can be configured in Homie */ #define MAX_CONFIG_SETTING_ITEMS 50 /**< Parameter, that can be configured in Homie */
#define PANIK_MODE_DEEPSLEEP 18000000000U /**< 5 hours in usecond */
#endif #endif

View File

@ -315,6 +315,9 @@ void onHomieEvent(const HomieEvent& event) {
case HomieEventType::MQTT_READY: case HomieEventType::MQTT_READY:
//wait for rtc sync? //wait for rtc sync?
rtcDeepSleepTime = deepSleepTime.get(); rtcDeepSleepTime = deepSleepTime.get();
Serial << rtcDeepSleepTime << " ms ds" << endl;
esp_sleep_enable_timer_wakeup( (rtcDeepSleepTime * 1000U) );
mode2MQTT(); mode2MQTT();
Homie.getLogger() << "MQTT 1" << endl; Homie.getLogger() << "MQTT 1" << endl;
@ -663,16 +666,10 @@ void setup() {
// Big TODO use here the settings in RTC_Memory // Big TODO use here the settings in RTC_Memory
// Configure Deep Sleep: //Panik mode, the Lipo is empty, sleep a long long time:
if (mConfigured && (deepSleepNightTime.get() > 0) && if ( SOLAR_VOLT(solarRawSensor.getAverage()) < MINIMUM_SOLAR_VOLT) {
( SOLAR_VOLT(solarRawSensor.getAverage()) < MINIMUM_SOLAR_VOLT)) {
Serial << deepSleepNightTime.get() << "ms ds " << SOLAR_VOLT(solarRawSensor.getAverage()) << "V" << endl; Serial << deepSleepNightTime.get() << "ms ds " << SOLAR_VOLT(solarRawSensor.getAverage()) << "V" << endl;
uint64_t usSleepTime = deepSleepNightTime.get() * 1000U; esp_sleep_enable_timer_wakeup(PANIK_MODE_DEEPSLEEP);
esp_sleep_enable_timer_wakeup(usSleepTime);
}else if (mConfigured && deepSleepTime.get()) {
Serial << deepSleepTime.get() << " ms ds" << endl;
uint64_t usSleepTime = deepSleepTime.get() * 1000U;
esp_sleep_enable_timer_wakeup(usSleepTime);
} }
if (mConfigured && if (mConfigured &&