ESP Easy and deep sleep mode (ESP8266 low power)

Last Modified May 27, 2021

The ESP8266 microcontroller is very well prepared to make the most of energy, with very low power modes.

To many people, these low-power modes seem like themes. mystics or occult, within the reach of very few people, a few chosen.

Here you will see that with ESPEasy they are very easy to use and what will they allow you huge energy savings.

What is deep sleep mode?

The deep sleep mode of the ESP8266 consists of the microcontroller falling into a deep sleep, with practically everything offexcept a very small part of the microcontroller that checks if it happens "something" which should cause the rest of the ESP8266 to wake up, coming out of its slumber.

An ESP8266 in deep sleep mode (asleep, and waiting for something happen, to wake up and do it) can consume as little as 8 to 20µA (1 mA = 1000 µA) while a NodeMCU board with its ESP8266 in deep sleep mode consumes around 8-20mA. This is between 500 and 1000 times more!

If you are interested in the topic of low consumption, I recommend that when you finish reading this article, you read this other one. Here you will find all the base you need to know to reach the low consumption Olympus with ESP8266:

What do I need to use the ESP8266 deep sleep mode?

You need two things: a complex hardware external precision that allows the microcontroller to go into a coma and complex programming, almost indecipherable, even for the best programmers in the world.

Maybe you are also interested in:  MH-Z19B FALSE CO2 Sensors

The hardware for deep sleep

The hardware you need is this:

And programming for deep sleep

The programming you need is this:

deepsleep, x

In this article I am going to tell you how to take advantage of this high technology easily.

ESPEasy and deep sleep

ESPEasy includes full support to put the processor in deep sleep mode and you can use it from your rules very easily.

The first thing you have to know is that RST pin must be connected to GPIO-16, this is necessary for the ESP8266 to get in and out of its comatose state. This is the use that you will give to the cable that I have taught you before, to make a bridge from RST to GPIO-16, as simple as this.

For the ESP8266 to enter that comatose state, you only have to call from a rule (or a command, for example):

deepsleep, x

Where "X" is the time, in microseconds, that you want the ESP8266 to be in deep sleep mode.

When that time has elapsed, the ESP8266 will come out of his deep coma and the execution will begin, exactly the same as if we just turned it on.

Here I explain the details about this mode.

This is what happens when the ESP8266 wakes up from its deep nap and ESP Easy starts working again:

  • It tries to connect via wifi to the defined SSID, and to the SSID2 if it is defined and SSID fails.
  • If you cannot connect and you have enabled the option Sleep on connection failure, it returns to deep sleep immediately (this is good if you have to do something with wifi and it is not available, why wait any longer, wasting energy?)
  • It will send all the sensor measurements at the same time (ignoring the delays that have been defined).
  • It will turn off and sleep for the number of seconds set in the Sleep Delay setting. Deepsleep uses a 32-bit internal counter in uSecs. That means it's running up to 4294 seconds, longer delays won't work. That is to say. longest sleep time is about 1 hour 11 minutes.
Maybe you are also interested in:  Comparison of CO2 sensors MH-Z19B vs Senseair S8

Wake up ESP8266 manually

If you specify a deepsleep, 0 the ESP8266 will enter deep sleep mode without a set time to wake you up.

You will have to wake up the device yourself connecting RST to GND, with a button, for example, or a simple cable.

This is a very useful mode if what we want is to do something like a door or window sensor with a magnetic sensor (which we will connect between RST and GND) and that will make the ESP8266 wake up the moment that contact closes, a few seconds or months have passed since the last time.

Coming out of deep sleep

When deep sleep mode is active, you cannot connect to the web interface. In fact, the ESP8266 is off and there is only a small timer circuit on to wake up the main core of the ESP8266 when the time comes.

There are three ways to get out of deep sleep mode:

Cold start

Turn off the ESP8266 and reconnect power. You will have 30 seconds to connect to the web interface and disable deep sleep mode (you will get information on the serial port).

Temporary deactivation of deep sleep using a bridge

If 30 seconds is too short for you, you can use this method.

Disconnect GPIO-16 from RST and connect it to GND. Reconnect the ESP8266.

Now deep sleep will be disabled and the ESP8266 will work normally, until you reconnect GPIO-16 to RST.

This requires a version of ESPEasy v2.0.0-dev6 or newer.

Factory reset

If all else fails, just perform a factory reset. You will lose all your settings!

The reset is done by connecting the RX and TX pins together while resetting the ESP8266. Turn off the device. Then, remove the connector between the RX and TX pins. Reboot and install ESPEasy firmware again.

Maybe you are also interested in:  3D printed box for CO2 meter

If this doesn't work, try loading the blank image to match the size of the memory installed on the device. Reboot and wait 5 minutes. Then load the firmware you want to use. Reboot and wait 5 minutes.


4 thoughts on “ESP Easy y el modo deep sleep (ESP8266 bajo consumo)”

  1. Hello Mario, another good article, thanks for the presentation.
    I have a beginner's question: while the ESP8266 is in deep sleep, does the OLED display keep on showing the last measured values? I suppose so, if not there would not even be time to see the measurements, but I would like you to confirm it.
    a greeting

    • Hello Jesus.

      I have not done tests with an OLED screen and deep sleep but I would say yes, the image is maintained while the ESP8266 is in deep sleep.

      In any case, it must be borne in mind that although OLED screens consume relatively little, they continue to consume (I would say between 5 and 25mA, depending on the brightness and how many pixels are on) so the ideal, if you want to achieve great autonomy, is to keep the OLED screen off and turn it on with a button that wakes up the ESP8266, turns on and updates the screen and turns it off again and to the deep sleep state after a few seconds so that you have time to read it comfortably.

      To achieve long autonomies, it is best to use an e-Ink screen, which has a negligible consumption when it is not being updated, as you can see in the article "Design of an ultra-low consumption CO2 meter"

  2. Thanks Mario, I'm thinking about it, let's see if I can clarify what I want to do first. I have also read that article, although without stopping much, and I have seen the screens, but they are more expensive. I said, if I find time and inspiration (in that order) I will try to make a meter only for low consumption, using the magnificent ideas that you expose in your articles.
    A greeting.


Leave a Comment