For the ESP32 see here.
As there is quite a bit of confusing documentation about the power management of the ESP8266, here’s a little overview.
We are going to use the Arduino core for ESP8266 because it seems to be more mature than Espressif’s own SDK. The latest release is 2.3.0 and contains SDK 1.5.3 and this article will refer to that version. The master
branch contains a few more convenience functions like wifi_fpm_auto_sleep_set_in_null_mode()
and WiFi.setSleepMode()
but we’ll ignore them here because it doesn’t look like there’s a new release coming any time soon.
The ESP8266 has 6 power states:
Fully on
|
Fully on, no Wifi configured Fully on, Wifi configured and reachable |
Auto Modem Sleep
|
|
Auto Light Sleep
|
|
Forced Modem Sleep
|
|
Forced Light Sleep
|
|
Deep Sleep
|
Waking up from 3 seconds of Deep Sleep and connecting to Wifi Waking up from Deep Sleep and going to Forced Modem Sleep immediately Waking up from Deep Sleep with RF_DISABLED |
Unfortunately there does not seem to be a mode where WiFi is off and the CPU will still sleep during delay()
.
This application note recommends to use light sleep instead of deep sleep when sleeping less than 2 seconds, but I don’t consider that very practical advice given the fact that you can’t use a timer to wake up from light sleep.
Further observations:
It seems that ESP.deepSleep(time, RF_CAL)
and ESP.deepSleep(time, RF_NO_CAL)
lead to identical behavior:
RF_CAL |
NO_RF_CAL |
I further noticed that connecting to Wifi after waking up from Forced Modem Sleep seems to take longer than after waking up from Deep Sleep:
Your document is extremely helpful. I am struggling to get my nodemcu / esp8266 to go to forced light sleep, or even auto light sleep.
https://stackoverflow.com/questions/52767240/light-sleep-with-gpio-wakeup-in-esp8266 Here is the question i have in detail, can you please help me resolve this problem.
The concerns i have is that i cannot get to sleep “well” and when i try to wake it up, it doesnt wake up.
Not sure whether you still have a problem with getting ESP8266 to sleep”Well” I have tried it and it works for me, you can check out the post on https://efcomputer.net.au/blog/esp8266-light-sleep-mode/
Really good analysis and really helpful for the community!
Thank you!
I would like to ask you one question:
I’m using a Wemos D1 mini with MQTT publish-subscribe interface. I need it to keep the power consumption as low as possible because it is battery supplied.
I use the controller to count down specified time that has to appear in a 7 segment display while counting!
Thinking about deep sleep while no time is specified, and waking after some external interrupt in the already existant buttons! but I’m not sure if any of the sleep types may keep the controller counting and displaying the time on the 7-segment while sleeping. like executing the countdown while displaying it and waking at the end to publish on the broker.
What would you recommend me?
Really thank you in advance for the paid attention,
Pedro Oliveira
You can sleep while doing something, such as displaying the time on a 7-segment display.
The key is to remember the device can sleep for a few miliseconds at a time. If you want to update your display once per second, you can easily sleep between updates.
There are a total of five different power modes. Active, modem sleep, light sleep, deep sleep, hibernation.
Some tasks may require an external latch or other component to maintain state during some sleep modes.
Hello,
thank for your post of the Sleep States.
But to understand you Pics correctly you should explain in a few words what you have measured.
Did you use a current probe?
And whats the resolution of it?
It is 100 mA per 100 mV???
Thanks for it…
Best regards Frank
I used a 1 Ohm shunt, so 1 mV means 1 mA.
Very interesting feature! I’m eager to test it! keep posting! can i share it?
why it seems to be more mature than Espressif’s own SDK?
how do you read that graph?