Enable DeepSleep on an ESP8266-01




About: IoT - Internet of Things. Iota - small thing. Thingamajig - An object whose name can't be recalled. Iotamajig - A little unnamed internet connected gizmo!

We all know how versatile the ESP8266-01 is. By "we", of course I mean the 6 people that are still reading this after seeing the title! Sure, it does have its limitations:

  • only 2 GPIOs
  • no analog GPIO
  • inability to use the ESP.deepSleep() function

We've looked at getting more GPIOs before here.

We'll look at analog options another time. But in this Instructable, we'll deal with the Deep Sleep issue.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Things You'll Need, or Maybe Want

You most likely have everything you need already. The basics:

We are going to be doing some detail soldering, so I also recommend something with clamps, hands, magnifier, and lights, like:

Step 2: About ESP.deepSleep()

When your IoT project is powered by a plug in the wall, you tend not to care too much about power consumption. But if you are going to power your project by batteries, every mA counts.

The video at the beginning of this Instructable shows the actual power consumption of a data logging module I developed. In the video, you can see that while in deep sleep, the unit is only drawing about 3mA. In actuality, the ESP and the other components of the circuit are only drawing micro amps, but the project makes use of a voltage converter and regulator because it's fed off of 12 volt batteries. Those 3 mA are lost power consumed by the ghosts of necessary evil..

The point is, if your circuit is spending most of its time doing nothing, you can really cut back its power use by leveraging the deepSleep() function. In my example, I went from using an almost constant 40 mA, and cut it down to 3 mA.

Code-wise, you do have to think a little differently. When programming with the Arduino IDE, a lot of your heavy lifting code will be in the loop() function. The deepSleep() function will essentially reset your ESP. So, any variables, loop counts, etc, they all get lost.

Your setup() function in effect becomes your loop. When your program has done all that it needs to, before the closing bracket, you just throw in:

//1,000,000 = 1 second

And of course this assumes we have the following include at the beginning of the sketch:

#include <ESP8266WiFi.h>

At the end of the time specified in the deepSleep() function, the ESP will reset, and start everything at the beginning again.

Here is some code, and ways to handle variable storage. But in this Instructable, we'll focus on the hardware mods.

Step 3: Cut Some Fine Wire

Our ESP-01 can NOT use deepSleep out of the box. We have to solder a wire across two pins. This looks difficult, but trust me, it is not as hard as it seems. Start with some fine wire and strip both ends. An eighth of an inch should work.

I used some 28 ga wire that I use for jumper wires on my breadboards. You could use single-strand wire, but I think it works a little better with multi-strand wires - the wires hold a bit of extra solder amongst themselves. Plus if the gauge is too big, you could remove a few strands to get to the size we need.

Step 4: Examine the End That Connects to the Chip

The chip on the esp is tiny. It would be next to impossible to solder a wire directly to the pin we need to access. Luckily, the pin we need to hit is on the corner of the board. So what we will do, is make sure our tinned jumper wire is well tinned (but not over-soldered), and still skinny and pointy like a needle.

Practice holding the wire end to the pin we need to connect to. If you can't easily poke it straight at the corner pin and make good contact, try a thinner wire, or use some snippers to cut the wire to a point.

Step 5: Solder the Wire to the Rst (reset) Pin

Once the wire is cut and tinned, I like to bend it into the rough shape that you see in the pictures.

Now, we'll solder one end to the Rst pin on the ESP. We do this end first because it helps hold the wire stable when we solder the other end.

Step 6: Solder the Other Wire End to the ESP Chip

This is the hardest part - but don't fret, it's not that bad!

Take the other end of the wire, and poke it at that corner pin of the ESP chip (see picture).

Using your finger (or I like to use a pin, needle, or toothpick - something small yet strong), and hold the wire with the end jabbing at that pin. You want to use something to hold it while you solder, so it doesn't spring back once you remove your iron.

Now, touch your iron to the wire - not at the pin - but close to the plastic wire jacket. Because the wire is so thin, the pre-tinned solder should instantly melt. As soon as you see it liquefy, remove the iron.

Step 7: Hot Glue It to Add Strength

Finally, hit the edge of the board and the wire with some hot glue.

This will help to make sure that you don't break that wire off as you swap the ESP in and out of other project boards.

Step 8: Concluding Thoughts

Using the deepSleep() function will probably get you the most bang for your buck on conserving power, but don't forget to look at other power drains:

  • Do you have any other components that are constantly using power? Try using a transistor or a relay to only turn them on when you need them.
  • LEDs - if you don't need a light on, kill it! That annoying red power LED on the ESP? hit one side of it with your soldering iron while gently prying it with a small screwdriver (pin, needle, toothpick, etc). If you compare the two pictures here, the main difference is I killed the red power LED on the voltage regulator. Another mA saved! (yes, I know the ESP is also out in the second picture - but trust me, the savings is from that LED!)

Now you know how to make your batteries run the distance - go get creative with your upgraded ESP8266-01!

1 Person Made This Project!


  • Made with Math Contest

    Made with Math Contest
  • Multi-Discipline Contest

    Multi-Discipline Contest
  • Robotics Contest

    Robotics Contest

13 Discussions


6 months ago

One note to keeping your variables alive after a reset:
If all you need is to store some numerical values over a reset (e.g. deep sleep), you might want to use my lib RTCVars https://github.com/highno/rtcvars (advertisement end) which has exactly this use case and offers a (hopefully) simple way to store and access variables in RTC memory which is soft reset "resistant".


8 months ago

Hey guys there is a way to make it button working? i mean press a button to reset the esp while in sleepmode(0); ? I have made a little wifi button door opener (it just send a command to my nodemcu) but i like to transofrm it with a battery in a portable button.

1 reply

Reply 8 months ago

Just realized now: reset pin and gnd = exit from deepsleep :P

Eric Brouwer

1 year ago

Thanks for sharing. I have been struggling with DeepSleep on my ESP8266-01's.
Now I know why.




Reply 2 years ago

I need to strip some stuff out of one of my project sketches so it's more "Instructable", but there are two routes I use for variables: EEPROM and local filesystem (SPIFFS). I tend to have bad luck with EEPROM for some reason, so putting data in a local file on the ESP has been my go-to route. In the end, a local file is just data across some addressed space on the chip, like EEPROM, so it's all about the same and will take some added libraries and coding to make work either way.


Reply 2 years ago

I'd really like you to explain this a bit more. I have had quite a bit of trouble altering my programs to enable deep sleep and yours is the first instructable I have seen on it.


2 years ago

All your instructables are based on an outdated module .ESP-12's and later are just as cheap and fix all the problems you write about . Thanks for the instructable though . have you put it on the ESP8266 forum?

2 replies

Reply 2 years ago

I find that "cheap" is relative to where you are willing to get them from - though I do agree, all ESPs are relatively cheap, and there are much more robust versions that will give you more bang for your buck. I just think we all get a little bit of enjoyment out of pushing components outside the limits they were designed for! Thanks for reading...


Reply 2 years ago

I bought 6 esp-12s at the start of my journey . Done everything I could and a lot they tell me I should not have, but they are still working, the ones I have opened and soldered, (4) .$3 on ebay from china which is the place that invented and manufactured them


2 years ago

Wow I'm one of the six :)

Nice instructable, thanks for sharing. Good to see that people are able to find solutions like this, the way of coding is new for me :)

1 reply

Reply 2 years ago

Wow, you might be number 7! Thanks for reading!


2 years ago

The modules I have bought lately have all been ESP-12.

Placing a small cap across RESET-> GPIO16_XPD pin does the job and the soldering is easy