problem with deep sleep time (esp_sleep_enable_timer_wakeup() suddenly/randomly stops)
Posted: Mon Jul 24, 2023 8:52 am
Hello All,
we have designed a data logger using esp32s3, and device wakes up after every set time, and collects data from sensor and goes to deep sleep.
But suddenly system is facing a issue where device is not waking from deep sleep after setting a time of 10mins.
Kindly note the below behaviour:
1] This issue is happening randomly.
2] device is waking up due to any external interrupts which we have set but timer wakeup
3] when device goes to deep sleep, unless and until external interrupt happens, device won't wakeup
4] when issue happens, device won't wakeup and collects data until external interrupt happens, before this issue and after external interrupt while device is in mode, device works fine, goes in deep sleep and comes out of it properly, and no data loss is been seen.
it's been found that when device won't wake up at set time, till external interrupt, that time device remains in deep sleep.
Please find the code below :
<-------------------------------------------------------------------------------------------------------------->
//set deep sleep time as sleep_time -> seconds is user defined
uint64_t sleep_time = seconds * uS_TO_S_FACTOR;
esp_err_t err = esp_sleep_enable_timer_wakeup(sleep_time);
printf("SLEEPING FOR %d SECONDS: %d\r\n\r\n", seconds, err);
//external interrupts to wakeup device from deep sleep
const int ext_wakeup_pin_1 = 12;
const uint64_t ext_wakeup_pin_1_mask = 1ULL << ext_wakeup_pin_1;
const int ext_wakeup_pin_2 = 14;
const uint64_t ext_wakeup_pin_2_mask = 1ULL << ext_wakeup_pin_2;
const int ext_wakeup_pin_3 = 1;
const uint64_t ext_wakeup_pin_3_mask = 1ULL << ext_wakeup_pin_3;
esp_sleep_enable_ext1_wakeup(ext_wakeup_pin_1_mask | ext_wakeup_pin_2_mask | ext_wakeup_pin_3_mask, ESP_EXT1_WAKEUP_ALL_LOW);
gettimeofday(&sleep_enter_time, NULL);
//delete/deinit watchdog timers
esp_task_wdt_reset();
esp_task_wdt_delete(NULL); //Unsubscribe Idle Task from TWDT
esp_task_wdt_status(NULL); //Confirm Idle task has unsubscribed
//Deinit TWDT after all tasks have unsubscribed
esp_task_wdt_deinit();
esp_task_wdt_status(NULL); //Confirm TWDT has been deinitialized
//start deep sleep
esp_deep_sleep_start();
<-------------------------------------------------------------------------------------------------------------->
Please let me know,
1] what is the cause of this issue AND
2] how to resolve this issue.
Thank you in advance.
we have designed a data logger using esp32s3, and device wakes up after every set time, and collects data from sensor and goes to deep sleep.
But suddenly system is facing a issue where device is not waking from deep sleep after setting a time of 10mins.
Kindly note the below behaviour:
1] This issue is happening randomly.
2] device is waking up due to any external interrupts which we have set but timer wakeup
3] when device goes to deep sleep, unless and until external interrupt happens, device won't wakeup
4] when issue happens, device won't wakeup and collects data until external interrupt happens, before this issue and after external interrupt while device is in mode, device works fine, goes in deep sleep and comes out of it properly, and no data loss is been seen.
it's been found that when device won't wake up at set time, till external interrupt, that time device remains in deep sleep.
Please find the code below :
<-------------------------------------------------------------------------------------------------------------->
//set deep sleep time as sleep_time -> seconds is user defined
uint64_t sleep_time = seconds * uS_TO_S_FACTOR;
esp_err_t err = esp_sleep_enable_timer_wakeup(sleep_time);
printf("SLEEPING FOR %d SECONDS: %d\r\n\r\n", seconds, err);
//external interrupts to wakeup device from deep sleep
const int ext_wakeup_pin_1 = 12;
const uint64_t ext_wakeup_pin_1_mask = 1ULL << ext_wakeup_pin_1;
const int ext_wakeup_pin_2 = 14;
const uint64_t ext_wakeup_pin_2_mask = 1ULL << ext_wakeup_pin_2;
const int ext_wakeup_pin_3 = 1;
const uint64_t ext_wakeup_pin_3_mask = 1ULL << ext_wakeup_pin_3;
esp_sleep_enable_ext1_wakeup(ext_wakeup_pin_1_mask | ext_wakeup_pin_2_mask | ext_wakeup_pin_3_mask, ESP_EXT1_WAKEUP_ALL_LOW);
gettimeofday(&sleep_enter_time, NULL);
//delete/deinit watchdog timers
esp_task_wdt_reset();
esp_task_wdt_delete(NULL); //Unsubscribe Idle Task from TWDT
esp_task_wdt_status(NULL); //Confirm Idle task has unsubscribed
//Deinit TWDT after all tasks have unsubscribed
esp_task_wdt_deinit();
esp_task_wdt_status(NULL); //Confirm TWDT has been deinitialized
//start deep sleep
esp_deep_sleep_start();
<-------------------------------------------------------------------------------------------------------------->
Please let me know,
1] what is the cause of this issue AND
2] how to resolve this issue.
Thank you in advance.