esp32: Add esp32.wake_on_gpio. #17518
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Some boards support waking up from deepsleep via GPIO pins (for instance ESP32C3, ESP32C6), but this is not currently supported by MicroPython. This commit adds support for waking with GPIO in a similar interface to waking with ext0, ext1, touch and ulp. This commit adds documentation for this new function as well.
This is a long standing request, with a lot of chatter online. Over the years there have been several attempts to add this (#15498, #13333 and #9583), but with no success. I also explain below why my approach is better (it is based on the existing PRs, so thanks to @m-cas, @puppet13th and @ondiiik).
Testing
Tested ESP32_GENERIC_C3with:
and checked that the relevant pins wake up from deepsleep.
Trade-offs and Alternatives
The existing PRs mentioned above modify
wake_on_ex1
, testing if the port is specifically ESP32C3. My solution adds awake_on_gpio
which is a similar interface, and tests for the SOC capabilities.