Start Back Next End
  
ZBasic System Library
ZBasic Microcontrollers
11
DeepSleep
Type
Subroutine
Invocation
DeepSleep(duration, startup)
Parameter
Method
Type
Description
duration
ByVal
integral
The number of microseconds to sleep.
startup
ByRef
anyType
The startup mode upon reawakening.
Discussion
This subroutine may be used to put the ESP8266 in deep sleep mode, substantially reducing power
consumption.  Only the on-board RTC is kept running while in deep sleep mode.
Startup Mode
Value
Meaning
0
Radio calibration after deep sleep is as specified in byte 108 of
esp_init_data_default.bin.
1
Recalibrate the radio after wakeup (increases current
consumption.
2
Do not recalibrate the radio after wakeup.
4
Disable the radio after wakeup.
Note that when the specified time expires, the GPIO16 pin will be pulled low.  This should be connected
to the RESET pin (usually via a diode) in order to apply a reset signal to wake up the device.  Because
the on-board RTC is kept running during deep sleep, you may store some parameter values (i.e. state
information) in the memory area of the on-board RTC to be used durint the post-sleep startup (see
RTC.MemRead and RTC.MemWrite).  The value of Register.ResetFlags() may be used to
determine the cause of the reset and therefore control what is done during startup.
Register.ResetFlags Values
Value
Meaning
0
Power-on reset.
1
Hardware watchdog reset.
2
Exception reset.
3
Software watchdog reset.
4
Software reset.
5
Deep sleep awakening reset.
6
External reset.
Previous page Top Next page