The ESP8266 has provided a deep sleep mode which has been implemented in micropython power management. Please see the document as below:
https://docs.micropython.org/en/latest/ ... rctrl.html
I write a demo for my IoT project, the sensor has a ESP8266 and one DHT22 sensor and the size of sensor's shell only about 60mm * 25mm * 10mm. To avoid the impact of DHT22 result, I put ESP8266 in deep sleep mode every ~70s. Paste code as below, I hope it is useful to you.
In additional, I test this code both in Aruba AP205 and Cisco WLC2504 with 3702i, they can hold the wifi association for this module during deep sleep and ESP8266 can get its network info in 1 second.
CAUTION: Please read below info carefully
The deep-sleep mode will shut down the ESP8266 and all its peripherals, including the WiFi (but not including the real-time-clock, which is used to wake the chip). This drastically reduces current consumption and is a good way to make devices that can run for a while on a battery.
To be able to use the deep-sleep feature you must connect GPIO16 to the reset pin (RST on the Adafruit Feather HUZZAH board).
Code: Select all
rtc = machine.RTC()
if machine.reset_cause() == machine.DEEPSLEEP_RESET:
print('woke from a deep sleep')
print('power on or hard reset')
sta_if = network.WLAN(network.STA_IF)
print('Wireless association is reserved!')
for i in range(10): #for wake test here
print('Before deep sleep, system working in [%s] seconds' % i)
print('Prepare to sleep in 2s')