Skip to content

Commit fcc9d43

Browse files
committed
docs/esp8266: Add info about using deep-sleep mode to quickref.
1 parent 32d7cf6 commit fcc9d43

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

docs/esp8266/quickref.rst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,28 @@ The I2C driver is implemented in software and works on all pins::
202202
i2c.readfrom(0x3a, 4, stop=False) # don't send a stop bit after reading
203203
i2c.writeto(0x3a, buf, stop=False) # don't send a stop bit after writing
204204

205+
Deep-sleep mode
206+
---------------
207+
208+
Connect GPIO16 to the reset pin (RST on HUZZAH). Then the following code
209+
can be used to sleep, wake and check the reset cause::
210+
211+
import machine
212+
213+
# configure RTC.ALARM0 to be able to wake the device
214+
rtc = machine.RTC()
215+
rtc.irq(trigger=rtc.ALARM0, wake=machine.DEEPSLEEP)
216+
217+
# check if the device woke from a deep sleep
218+
if machine.reset_cause() == machine.DEEPSLEEP_RESET:
219+
print('woke from a deep sleep')
220+
221+
# set RTC.ALARM0 to fire after 10 seconds (waking the device)
222+
rtc.alarm(rtc.ALARM0, 10000)
223+
224+
# put the device to sleep
225+
machine.deepsleep()
226+
205227
OneWire driver
206228
--------------
207229

0 commit comments

Comments
 (0)