I have a customboard running an ESP32-S3 WROOM Module. One line on this module is linked to an external button with a pull-up resistor on GPIO13 and I want this button to operate as a DeepSleep wakeup source.
For the majority of the time, the board wakes and reports that the button was successfully pressed. Infrequently though, I have an issue where it reports as a power-reset esp_sleep_get_ext1_wakeup_status() reads 0 and esp_sleep_get_wakeup_cause() != ESP_SLEEP_WAKEUP_EXT1
I've looked through as many resources as I can find and I cant see any reason to explain this odd behaviour. I'm running ESP-IDF Version 4.4.1. The issue isn't specific to one board either - I have 10 boards that all exhibit this same issue infrequently.
Any help or suggestions would be much appreciated.
Code: Select all
void enter_deep_sleep(void) {
ESP_LOGI(TAG, "Entering Deep Sleep");
// Application Specific Shutdown Here
/**/
// Enable Wakeup Sources
ESP_ERROR_CHECK(esp_sleep_enable_timer_wakeup(DEEP_SLEEP_PERIOD_MICROSECONDS)); // Wake after 30s,
ESP_ERROR_CHECK(esp_sleep_enable_ext1_wakeup((1 << BTN_SNS_GPIO), ESP_EXT1_WAKEUP_ALL_LOW)); // Or on RGB Button Press
// Actually Sleep Now
esp_deep_sleep_start();
}
void app_main(void) {
ESP_LOGI(TAG, "\n\n\tController Version %u.%u.%u - %s", FW_VERSION[0], FW_VERSION[1], FW_VERSION[2], git_commit_id);
// Check how / why we rebooted
uint64_t wakepins = esp_sleep_get_ext1_wakeup_status();
ESP_LOGE(TAG, "Wake GPIO Source %llu (Bit %d)", wakepins, ffs(wakepins & wakepins)); // Should only ever have 1 bit set
esp_sleep_wakeup_cause_t wakeup_reason = esp_sleep_get_wakeup_cause();
// Here, we check why we woke up
// wakepins == 0 and wakeup_reason != ESP_SLEEP_WAKEUP_EXT1
/*********** Rest of our application code *****************/
}