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.
The hardware for deep sleep
The hardware you need is this:
And programming for deep sleep
The programming you need is this:
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):
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.
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:
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.
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.
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.
HAS IT BEEN INTERESTING?
DON'T MISS FUTURE ITEMS LIKE THIS!
SUBSCRIBE TO THE NEWSLETTER AND JOIN THE TELEGRAM GROUP AND DO NOT MISS ANYTHING OF THE BEST.