ESP32 Deep Sleep is not waking up on timer

stern1710
Posts: 4
Joined: Sun Jul 12, 2020 2:26 pm

ESP32 Deep Sleep is not waking up on timer

Postby stern1710 » Mon Jul 13, 2020 12:40 pm

Hardware:
Board: ESP32 DevKit V1
Core Installation version: 1.0.4 (Board Manager ESP32 by Espressif Systems)
IDE name: Arduino 1.8.12
Flash Frequency: 80MHz
PSRAM enabled: No
Upload Speed: 921600
Computer OS: Windows 10 1909

My Problem
I tried to get a bit into the deep sleep states of the ESP32 and waking it up by an timer interupt. For this, I chose to try out the sample provided under Files -> Examples -> ESP32 -> DeepSleep -> TimerWakeUp, flashed it successfully to the board (at least so I assume, works for other small projects as well) and started it up. As it unfortuanitly seems, after calling esp_deep_sleep_start(); the ESP32 is not waking up again. I tried a bit around with short time periods (e.g. 1 second), but that did not produce any other results than the board not.
The ESP32 is connected via a Micro-USB to USB-A cable to my computer, both as the data line for the Serial Monitor and flashing as well as the power source. No further components are connected to the microcontroller. Other functionalities such as WiFi or networking (using MQTT) is working fine. I don't have a second ESP32 module, so cannot verify this behaviour with other hardware sadly.
What am I doing wrong / not seeing? Anything wrong with my settings? Not having installed any the necessary libraries?

Code
  1. #define uS_TO_S_FACTOR 1000000ULL  /* Conversion factor for micro seconds to seconds */
  2. #define TIME_TO_SLEEP  5        /* Time ESP32 will go to sleep (in seconds) */
  3.  
  4. RTC_DATA_ATTR int bootCount = 0;
  5.  
  6. /*
  7. Method to print the reason by which ESP32
  8. has been awaken from sleep
  9. */
  10. void print_wakeup_reason(){
  11.   esp_sleep_wakeup_cause_t wakeup_reason;
  12.  
  13.   wakeup_reason = esp_sleep_get_wakeup_cause();
  14.  
  15.   switch(wakeup_reason)
  16.   {
  17.     case ESP_SLEEP_WAKEUP_EXT0 : Serial.println("Wakeup caused by external signal using RTC_IO"); break;
  18.     case ESP_SLEEP_WAKEUP_EXT1 : Serial.println("Wakeup caused by external signal using RTC_CNTL"); break;
  19.     case ESP_SLEEP_WAKEUP_TIMER : Serial.println("Wakeup caused by timer"); break;
  20.     case ESP_SLEEP_WAKEUP_TOUCHPAD : Serial.println("Wakeup caused by touchpad"); break;
  21.     case ESP_SLEEP_WAKEUP_ULP : Serial.println("Wakeup caused by ULP program"); break;
  22.     default : Serial.printf("Wakeup was not caused by deep sleep: %d\n",wakeup_reason); break;
  23.   }
  24. }
  25.  
  26. void setup(){
  27.   Serial.begin(115200);
  28.   delay(1000); //Take some time to open up the Serial Monitor
  29.  
  30.   ++bootCount;
  31.   Serial.println("Boot number: " + String(bootCount));
  32.  
  33.   print_wakeup_reason();
  34.  
  35.   esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR);
  36.   Serial.println("Setup ESP32 to sleep for every " + String(TIME_TO_SLEEP) +
  37.   " Seconds");
  38.  
  39.   //esp_deep_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_OFF);
  40.   //Serial.println("Configured all RTC Peripherals to be powered down in sleep");
  41.  
  42.   Serial.println("Going to sleep now");
  43.   Serial.flush();
  44.   esp_deep_sleep_start();
  45.   Serial.println("This will never be printed");
  46. }
  47.  
  48. void loop(){  //This is not going to be called }

stern1710
Posts: 4
Joined: Sun Jul 12, 2020 2:26 pm

Re: ESP32 Deep Sleep is not waking up on timer

Postby stern1710 » Sun Aug 14, 2022 8:50 am

For anyone wondering, the device itself was defect. Ordering a new one and flashing the exact same code fixed it.

Who is online

Users browsing this forum: No registered users and 58 guests