Hello Crami25,
Thank you for your help.
I took the time to try, to test.
For sleep, it's OK.
I made a small example but it doesn't work every time ???
On the other hand, I wish to wake up with the buttons.
I've searched the schematics:
Button A GPIO39
Button B GPIO38
Button C GPIO37
Following the example of this site:
https://randomnerdtutorials.com/esp32-external-wake-up-deep-sleep/
ext0
In this example, the ESP32 wakes up when the GPIO 33 is triggered to high:
esp_sleep_enable_ext0_wakeup(GPIO_NUM_33,1); //1 = High, 0 = Low
Instead of GPIO 33, you can use any other RTC GPIO pin.
#include <M5Stack.h>
#define uS_TO_S_FACTOR 1000000 /* Conversion factor for micro seconds to seconds /
#define TIME_TO_SLEEP 10 / Time ESP32 will go to sleep (in seconds) */
//#define BUTTON_PIN_BITMASK 0x8000000000
void setup()
{
Serial.begin(115200);
M5.begin(true, false, true);
esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR);
Serial.println("Setup ESP32 to sleep for every " + String(TIME_TO_SLEEP) + " Seconds");
esp_sleep_enable_ext0_wakeup(GPIO_NUM_39,0); //1 = High, 0 = Low
//esp_deep_sleep_start(); //entre en someil profond
}
void loop() {
M5.update();// update button state
if (M5.BtnA.wasReleased())
{
esp_sleep_enable_ext0_wakeup(GPIO_NUM_39,0); //1 = High, 0 = Low
}
if (M5.BtnB.wasReleased())
{
esp_deep_sleep_start(); //entre en someil profond
}
if (M5.BtnC.wasReleased())
{
M5.Lcd.fillScreen(WHITE);
M5.Lcd.setTextColor(BLUE);
M5.Lcd.setBrightness(100);
M5.Lcd.setTextSize(2);
M5.Lcd.setCursor(40, 60);
M5.Lcd.print("Temperature: ");
}
}