m5stack / M5Unified

Unified library for M5Stack series
MIT License
330 stars 58 forks source link

M5Paper wakes too soon from deep sleep when touch wakeup is enabled - with solution #91

Open sbesselsen opened 1 year ago

sbesselsen commented 1 year ago

When I call M5.Power.deepSleep(10 * 1000000, true) on the M5Paper, the deep sleep always ends after around 2 seconds with esp_sleep_get_wakeup_cause() == ESP_SLEEP_WAKEUP_EXT0. I think this is because the behavior of GPIO pin 36 is not as PowerClass::deepSleep() expects. If I remove the call to esp_deep_sleep_start() and instead monitor the state of pin 36 for a while, I see it going from HIGH to LOW after about 2 seconds and then staying there. This is what triggers the ext0 wakeup. I have solved this by creating my own version of deepSleep() with 2 modifications:

I can confirm that with these two changes, deepSleep with touch wakeup works as expected, and when I remove either of these two changes, it reverts to its erroneous behavior.

I do notice that all this adds around another 4 seconds before esp_deep_sleep_start() is actually called, so if the wakeup timing needs to be precise, perhaps some adjustment of the remaining micro_seconds would be in order, but that is not a decision for me to make.

Hope this helps!

lovyan03 commented 11 months ago

Hello, @sbesselsen I am sorry for the late response. Thank you for giving me this information. Since the develop branch has been updated, if there are no problems, it will be reflected in the next update release.

mdxs commented 7 months ago

I assume this has been resolved; there have been several releases since. If so, the ticket can be closed as resolved.