diff options
author | Damien George <damien.p.george@gmail.com> | 2016-04-21 12:01:50 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2016-04-21 12:01:50 +0100 |
commit | fcc9d43c6dbef8db517a2179de88ff3da31e995f (patch) | |
tree | fc33053daf44314df951b02402d56316dd9f94b9 /docs/esp8266/quickref.rst | |
parent | 32d7cf6e441660caed00620309d1faa4b7df5dd4 (diff) | |
download | micropython-fcc9d43c6dbef8db517a2179de88ff3da31e995f.tar.gz micropython-fcc9d43c6dbef8db517a2179de88ff3da31e995f.zip |
docs/esp8266: Add info about using deep-sleep mode to quickref.
Diffstat (limited to 'docs/esp8266/quickref.rst')
-rw-r--r-- | docs/esp8266/quickref.rst | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/docs/esp8266/quickref.rst b/docs/esp8266/quickref.rst index febad37366..30687db710 100644 --- a/docs/esp8266/quickref.rst +++ b/docs/esp8266/quickref.rst @@ -202,6 +202,28 @@ The I2C driver is implemented in software and works on all pins:: i2c.readfrom(0x3a, 4, stop=False) # don't send a stop bit after reading i2c.writeto(0x3a, buf, stop=False) # don't send a stop bit after writing +Deep-sleep mode +--------------- + +Connect GPIO16 to the reset pin (RST on HUZZAH). Then the following code +can be used to sleep, wake and check the reset cause:: + + import machine + + # configure RTC.ALARM0 to be able to wake the device + rtc = machine.RTC() + rtc.irq(trigger=rtc.ALARM0, wake=machine.DEEPSLEEP) + + # check if the device woke from a deep sleep + if machine.reset_cause() == machine.DEEPSLEEP_RESET: + print('woke from a deep sleep') + + # set RTC.ALARM0 to fire after 10 seconds (waking the device) + rtc.alarm(rtc.ALARM0, 10000) + + # put the device to sleep + machine.deepsleep() + OneWire driver -------------- |