#47 Power Saving with ESP8266 (Sleep Mode) Tutorial with some Tricks

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
crey YouTubers here is the guy with a Swiss accent again esp8266 are quite power hungry this can be a problem for applications if we want to run them from batteries in which situation does the ESP chip use this power which possibilities exist to reduce the power hunger are there any tricks necessary in this video I try to answer these questions let's start with the esp8266 as we know it as a connected device for my tests I use a bare esp-12e module on a breadboard i mounted it on the breadboard friendly PCB shown in one of my former videos you find the link below in the comments the pins are connected as usual gpio 0 to high if not in programming mode GPO 15 to ground and reset and Chip enable both to VCC for our tests I connect the module via a 1 ohm resistor to the ground of the bench power supply and VCC is connected via my bench multimeter to the power supply my oscilloscope measures the voltage of the resistor because the multimeter and the 1 ohm resistor reduce the voltage I increase the supply to 3.5 volts like that I make sure that the ESP module always get enough VCC the multimeter shows the average current used by the module in milliampere the oscilloscope shows the voltage of the resistor because I choose the resistor as 1 ohm we get a simple relation the current in milliampere is the same value as the voltage displayed on the oscilloscope in molt so we start with a simple sketch the blink sketch only without LED because the current drawn by the LED would distort our measurement the Wii is switched on but without a connection the multimeter shows 70 milliamp with small peaks in the 80s the oscilloscope shows a completely different picture most of the time the current is around 70 milliamp but Peaks go up to 300 milliamp these are the famous peaks of the esp8266 which can create troubles if the board is connected to a Serial adapter without a big decoupling capacitor the Peaks are only one 1 millisecond long and therefore do not increase the average current much from time to time there are more such Peaks because the Wii module has to send some data during this period the average current increases to 80 milliamp so the used current increases with load of the wi connection these Peaks are a real pain if you look at the video of Kevin Dar you see that he uses real beefy voltage Regulators just because of these Peaks I post the links to his video into the comments so let's do a quick experiment what happens with the Peaks if I connect decoupling capacitors of different sizes directly to the board I start with a 100 microfarad capacitor we see no big difference the Peaks are still nearly 300 milliamp only a little shorter the next is a 330 microfarad condenser here the Peaks are about 200 milliamp with a 1,000 microfarad capacitor the Peaks are just above 120 milliamp and with 2,200 microfarads there are no more visible Peaks so we can summarize first if we need a continuous Wi-Fi connection the esp8266 needs at least 75 milliamp in average this means that this four cell battery from a quadcopter project with 2,200 milliamp hour lasts about 4 to 5 days if we use a very good switching power supply this is at least longer than my iPhone but sure nothing outstanding and second a at least 1,000 microfarad decoupling capacitor can reduce the Peaks considerably so for low energy designs we have at least one learning use a big decoupling condenser to reduce the need for a big Power regulator fortunately the developers of the ESP built in some features to reduce the power consumption of the chip a look to the block diagram in the data sheet shows that the ESP chip consists of two parts the wi modem here in blue and the MCU in yellow and the second diagram in the same data sheet shows that the ESP offers four different Power modes the first we tested already the next we test is the modem sleep mode here the blue part of the chip is Switched Off in this state no Wi-Fi connection is possible so we switch the wi with the command wi. mode off the spikes disappear immediately but the average current stays at around 70 milliamp we gain probably a few hours very disappointing the chip obviously does not go into the modem sleep mode therefore we need a different approach the commands wiy do Force sleep the new sketch obviously works if the modem is off we see no Peaks and the current is about 15 milliamp success with 15 milliamp we get a theoretical life of 27 days unfortunately the commands wi. Force sleep did not work with a running wi connection so for the moment I will not use them actively the only area that are useful for me is if I want to use my ESP and do not need wi at all for my application if you know more please post it in the comment so let's test the most aggressive mode the deep sleep mode the Arduino IDE offers a few ESP specific apis one of these commands is the one we are looking for esp. deep sleep this sounds promising so let's try this one to use this command we have to add a connection from gp6 to the reset pin not a big deal and we have to put the command esp. deep sleep somewhere in the sketch as soon as the sketch arrives at this command it puts the chip for a number of micros seconds in a deep sleep mode after that time the ESP restarts from scratch into the mode specified it loses all memory content and it also does not know where it was in the sketch if you want to know how to deal with this fact you can have a look at my video about watch doog timers I enclose the link in the comment below but let's come back to our problem reduce the power consumption let's try our sketch from before in the loop we call the Sleep command and Watch What Happens nothing the loop continues as if the command would not exist only if we add a delay 100 behind the command it executes as expected if we look at the serial monitor we see the first text appear but Loop two does not appear the execution stops and after a while the usual Mumbo jump jumbo shows us that the ESP reboots from scratch it writes the two lines and then the ESP hits the high again the text Loop two is never reached let's look now at our instruments the multimeter shows two distinct States one with a current of around 70 milliampere as seen before and in the second state for a long time it shows a current of only 600 microampere which is 1,000 times smaller this is very promising with the same battery as before the ESP could sleep very very long in this mode the switching power supply would probably use much more current than the ESP itself for sure it would suffice for a winter sleep like the maruts here in the mountains of Switzerland if we look at the oscilloscope we see the two stat if the sketch is running it behaves exactly as we saw before with all the spikes Etc after the Sleep command there is no current visible anymore we also can boot into a state where the modem stays off we just use the value wake RF disabled instead of wake RF default this has the same effect as the command wifey. force sleep and the consumption is is 15 milliamp if not in deep Sleep we could now stop the video and be happy that we solved the problem but there are a few additions which could be interesting for you first the esp8266 keeps its status stored so if you switched the modem off and load another sketch where you do not explicitly switch the modem on it stays off even if you use the wi mode command reset also does not help during my experiments this led to weird reactions of my ESB chip but at the end I was always able to get it back to life and another fact I discovered during my experiments the current drawn in the deep sleep mode heavily depends on VCC because of my layout VCC was a little more than 3.3 volt during deep sleep and the measured current was around 60 microampere without the different probes you should be able to get much closer to 3.3 volts then the current is only 20 microampere which is closer to specifications of the Chip And the winter sleep would be three times longer and last but not least I found a very interesting article of Riner Ox he uses Ram in the RTC memory to store data which has to survive a deep sleep period this is a very important fact because Ram has no limitations as e proms have in my iot videos I used the e prom to save data during reset this fact is so important that I plan another video about that Ram stay tuned thanks for watching till the end I hope this video was useful or at least interesting for you bye
Info
Channel: Andreas Spiess
Views: 92,155
Rating: undefined out of 5
Keywords: sleep mode, esp8266, esp-12E, arduino, diy, electronics, hobby
Id: 6SdyImetbp8
Channel Id: undefined
Length: 12min 27sec (747 seconds)
Published: Thu Feb 25 2016
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.