File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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+
205227OneWire driver
206228--------------
207229
You can’t perform that action at this time.
0 commit comments