Esp_sleep_get_wakeup_cause returns always 0

When I use the deep sleep examples from the Seeed Wiki on my XIAO ESP32S3, esp_sleep_get_wakeup_cause returns always 0 (ESP_SLEEP_WAKEUP_UNDEFINED) instead of ESP_SLEEP_WAKEUP_EXT0 and ESP_SLEEP_WAKEUP_TIMER. I’m using Arduino IDE 2.2.1 with ESP32 environment 2.0.14 (V2.0.11 has the same problem).
Is anyone aware of the problem? Is there a work around?
Bernhard

14:22:07.329 → ESP-ROM:esp32s3-20210327
14:22:07.329 → Build:Mar 27 2021
14:22:07.329 → rst:0x15 (USB_UART_CHIP_RESET),boot:0x8 (SPI_FAST_FLASH_BOOT)
14:22:07.329 → Saved PC:0x4201ecc2
14:22:07.329 → SPIWP:0xee
14:22:07.329 → mode:DIO, clock div:1
14:22:07.329 → load:0x3fce3808,len:0x44c
14:22:07.329 → load:0x403c9700,len:0xbe4
14:22:07.329 → load:0x403cc700,len:0x2a68
14:22:07.329 → entry 0x403c98d4
14:22:08.414 → Boot number: 1
14:22:08.414 → Wakeup was not caused by deep sleep: 0
14:22:08.414 → Setup ESP32 to sleep for every 10 Seconds
14:22:08.414 → Going to sleep now

1 Like

I’m having the same problem.
Looks like its the Serial Monitor connection. From what I understand, the Arduino Serial Monitor uses DTR and RTS control signals. These send a reset signal to the device when the monitor is connected. Since the device connects to the serial port when it wakes up, the result is the device being reset and the esp_sleep_get_wakeup_cause is 0.
I hooked up an LED (with a resistor) and added some code so it would blink out the esp_sleep_get_wakeup_cause.
When connected to the serial monitor, the esp_sleep_get_wakeup_cause was always 0. But when I turned the monitor off, the LED blinks the expected value.

Hi there ,
There’s a bug in the macro, for the callback I believe, “esp_sleep_get_wakeup_cause.”

change the type and it works…
HTH
GL :slight_smile: PJ :v:

you check this out? in the ESP_IDF

The following wake up sources are demonstrated in this example (refer to the Wakeup Sources documentation for more details regarding wake up sources):

  • Timer: An RTC timer that can be programmed to trigger a wake up after a preset time. This example will trigger a wake up every 20 seconds.
  • EXT0: External wake up 0 can trigger wakeup when one predefined RTC GPIO is at a predefined logic level. This example uses GPIO25 in ESP32 or GPIO3 in ESP32-S2/S3 to trigger a wake up when the pin is HIGH. (This wake up source is only available on ESP32, ESP32-S2, and ESP32-S3.)
  • EXT1: External wake up 1 which is tied to multiple RTC GPIOs. This example uses GPIO2 and GPIO4 to trigger a wake up with any one of the two pins are HIGH. (This wake up source is available on ESP32, ESP32-S2, ESP32-S3, ESP32-C6 and ESP32-H2.)
  • GPIO: Pads powered by VDD3P3_RTC can be used to trigger a wake up from deep sleep. You may choose the pin and trigger level in menuconfig. (This wake up source is unavailable on ESP32, ESP32-S2, ESP32-S3 and ESP32-H2.)
  • Touch: Touch pad sensor interrupt. This example uses touch pads connected to GPIO32, GPIO33 in ESP32 or GPIO9 in ESP32-S2/S3 to trigger a wake up when any of the pads are pressed.
  • ULP: Ultra Low Power Coprocessor which can continue to run during deep sleep.

Note: If using the IDF , Some wake up sources can be disabled via configuration (see section on project configuration)

Warning: On ESP32, touch wake up source cannot be used together with EXT0 or ULP wake up source.
Also pretty sure You CAN use other IO pins, But you need to use the pull_up & Pull_down resistors to do so.