

minimal example for entering interrupt-based deep sleep // no #include necessary // enter deep sleep ESP.


registering a on-wakeup callback void fpm_wakup_cb_func1 () wifi_fpm_set_wakeup_cb ( fpm_wakup_cb_func1 ) Output pin states during sleep in order to get timer-based light sleep to work correctly, this callback is actually mandatory (see below).
ESP01 DEEP SLEEP CODE
optionally one can register a callback method that is invoked on waking (this is run just before the main code continues to execute).light sleep is entered fast, so you might want to flush() any pending output streams before entering it.light sleep only suspends the CPU, so after waking up the code continues to run where it left off.Up to 508 bytes of user memory can be used to preserve data between sleep cycles (see Arduino documentation of ESP.rtcUserMemoryWrite()/ ESP.rtcUserMemoryRead() and the handy RTCMemory library the Low Power Demo uses memcpy and memset to write/read to RTC)

the only memory that is maintained between resets is that of the RTC chip, including information about the cause of the last reset (external or timer-based wake-up).waking up from deep sleep is through resetting the chip, code starts again at the beginning of setup().The Wi-Fi modem is turned off in all sleep modes, so it is necessary to restart/reconnect the WiFi when waking up from any sleep mode. This document summarizes my empirical findings/insights into less well-documented aspects of deep sleep and (so-called ‘forced’) light sleep, with code examples. Tutorials on the ESP8266’s sleep modes typically focus on the differences in chip activity states and power consumption between modes, but I found them lacking when it came to documenting their respective support/usage of external wake-up vs. ESP8266 (ESP-12F) deep sleep and light sleep with Arduino
