Hi Felix,
Many thanks for your comments - I appreciate them!
That said, I am curious to know your motivation to put ESP32 into deep sleep while running from USB?
I am asking because the overall power consumption of M5CoreInk with ESP32 in deep or light sleep is about the same.
Because the DeepSleep wakes by re-running the setup() code, whereas the LightSleep wakes by just continuing from the line after the "esp_light_sleep_start()" command.
This means that you can't use the same sleep code when running (ie.charging) on USB as you do when running on Battery.
And specifically the basic example software such as "github.com/m5stack/M5Core-Ink/tree/master/examples/Basics/RTC_Clock" just go to DeepSleep, and when connected to USB power (ie. when on-charge) never wake to update the time or anything again, until they wake again when the USB is disconnected (which sometimes doesnt happen reliably either).
(IE. one would have to write extra different sleep-code which would not have been necessary if the RTC-interrupt-pin was connected to an ESP32-RTC-GPIO.)
However, as I said one can add a:
esp_sleep_enable_timer_wakeup(seconds * 1000000); // or * 1100000
into the https://github.com/m5stack/M5Core-Ink/blob/master/src/M5CoreInk.cpp:
int M5CoreInk::shutdown(int seconds) {
code, which then uses a timer to wake the ESP32 from DeepSleep when on USB, and not the RTC-interrupt-to-GPIO19.
Although this is not ideal as you then can't use any of the BM8563-RTCs Weekly or CountDown-Timer functions to wake the ESP32 from DeepSleep when being charged.