Hello, I want the ESP32 to enter deep sleep until a button is pressed and it wakes up, but I'm not being able to do so. I tried the following:
#include <esp_sleep.h>
#define BUTTON_PIN 21
void setup() {
Serial.begin(9600);
}
void loop() {
Serial.println("Going to sleep in 2 seconds");
delay(2000);
esp_sleep_enable_ext0_wakeup((gpio_num_t)BUTTON_PIN, LOW);
esp_deep_sleep_start();
Serial.println("Just woke up!");
}
I don't know if the Just Woke Up message isn't being printed because the board is not waking up or if it has something to do with the serial monitor connection upon coming back from sleep. How should I modify my code? Thanks