I have the same issue.
I'm also using an ESP32-C3, and I get ESP_SLEEP_WAKEUP_UNDEFINED (i.e. 0) as the reason for waking after deep sleep, instead of ESP_SLEEP_WAKEUP_GPIO (i.e. 7) when I push a button to wake it from deep sleep.
It does wake up from deep sleep, but gives the wrong reason.
Code: Select all
// In setup:
esp_sleep_source_t thecause = get_wakeup_cause();
printf("Woke up for reason: %d.\n", thecause);
// Prints:
// Woke up for reason: 0.
esp_reset_reason_t resetreason = esp_reset_reason();
dprintf("resetreason: %d.\n", resetreason);
// Prints:
// resetreason: 1.
(...)
Code: Select all
// Later on, I tell it to go into deep sleep:
// Have to use a pin <= GPIO 5 to wake from deep sleep via GPIO
printf("Pin 3 validity: %d\n\r", (int) esp_sleep_is_valid_wakeup_gpio((gpio_num_t) 3));
printf("Pin 4 validity: %d\n\r", (int) esp_sleep_is_valid_wakeup_gpio((gpio_num_t) 4));
printf("Pin 5 validity: %d\n\r", (int) esp_sleep_is_valid_wakeup_gpio((gpio_num_t) 5));
// Prints:
// Pin 3 validity: 1
// Pin 4 validity: 1
// Pin 5 validity: 1
// Now setting GPIO dead interrupts to wake from sleep.
esp_err_t deepsleepresult = esp_deep_sleep_enable_gpio_wakeup(
((1ULL<<3) | (1ULL<<4) | (1ULL<<5))
, ESP_GPIO_WAKEUP_GPIO_HIGH);
// Note, my buttons are connected to high via a 1k resistor, when the button is pressed.
printf("deepsleepresult was %d.\n", (int) deepsleepresult);
// Prints:
// deepsleepresult was 0.
So it looks like
esp_reset_reason() works, but
get_wakeup_cause() does not. It should return ESP_SLEEP_WAKEUP_GPIO (which is 7), instead of ESP_SLEEP_WAKEUP_UNDEFINED (which is 0).
Can Espressif please confirm this bug?
I noticed another thread here with the same issue:
https://esp32.com/viewtopic.php?t=29054