Created
June 21, 2020 21:52
-
-
Save metoikos/cc776e9fff9514c3cc5aa695e2079021 to your computer and use it in GitHub Desktop.
Micropython deepsleep
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import machine | |
| def deep_sleep(self, msecs): | |
| # configure RTC.ALARM0 to be able to wake the device | |
| rtc = machine.RTC() | |
| rtc.irq(trigger=rtc.ALARM0, wake=machine.DEEPSLEEP) | |
| # set RTC.ALARM0 to fire after Xmilliseconds, waking the device | |
| rtc.alarm(rtc.ALARM0, msecs) | |
| # put the device to sleep | |
| machine.deepsleep() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment