Skip to content

Instantly share code, notes, and snippets.

@metoikos
Created June 21, 2020 21:52
Show Gist options
  • Save metoikos/cc776e9fff9514c3cc5aa695e2079021 to your computer and use it in GitHub Desktop.
Save metoikos/cc776e9fff9514c3cc5aa695e2079021 to your computer and use it in GitHub Desktop.
Micropython deepsleep
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