Wake ESP8266 by input signals during Deep Sleep the same way as Pin Change Interrupts

ESP8266 is very popular among IOT enthusiasts due to it’s builtin WiFi capabilities which keep our Fun Gadgets connected together. Normally it draws 215 mA current during data transmission and 0.9 mA are consumed during idle conditions when ESP8266 is not doing anything for us except keeping itself connected to our WiFi network. It’s Deep Sleep function is superb with 60 µA current consumption which is suitable in our Battery Powered Projects such as Weather Station, where it is required to take few readings during day or night and send them to the server and rest of time, ESP8266 keep itself under deep sleeps.

Sometimes, We require publishing some sort of output to our server and battery is only option to power our project. As ESP8266 does not support interrupts during deep sleep, how can We accomplish this task under this particular scenario?

Here, is a workaround, using couple of simple electronic components along with CH_PD, our ESP8266 will respond back to us even during deep sleep. Normally Reset, CH_PD, GPIO-0 and GPIO-2 are pulled up using 10 K resistors and GPIO-15 is pulled down the same way. But here we’ll pull CH_PD pin down using 10 K resistor.

Let’s suppose we have a Push Button attached to our Battery Powered ESP8266 and we want to publish it’s state to our server which is then proceeded to switch a relay connected to some other ESP8266.

Circuit Diagram:

  • Connect one side of Push Button to VCC and other side to a GPIO let’s suppose GPIO-4
  • GPIO side of Push Button is pulled down using 10 K resistor
  • Using a diode, GPIO is connected to CH_PD pin of ESP8266
  • An other GPIO such as GPIO-12 is also connected to CH_PD using a diode in the same way.

When Push Button is pressed, It pulls CH_PD to HIGH which switches ESP8266 ON. In the mean time, other GPIO (GPIO-12, as supposed earlier) connected to CH_PD is defined as OUTPUT and switched to HIGH as early as possible in setup() function. ESP8266 boots up, waits for connection to server, publish the output and check for Push Button to be released. As soon as Button is released and information is published to server already, ESP8266 switches GPIO (GPIO-12, as supposed earlier) from HIGH to LOW and ESP8266 switches to OFF.

There are two Push Buttons attached to ESP8266 (at GPIO-5 and GPIO-4) in schematics shown above. ESP8266 responds to both of buttons in same manner identifies them individually. Here is an example sketch which uses ESPMetRED Library for communicating ESP8266 to Node-Red.

Example Sketch:

2 thoughts on “Wake ESP8266 by input signals during Deep Sleep the same way as Pin Change Interrupts

  1. Jason says:

    Hi Ahmed. Nice post. Can you please post a diagram of the circuit? I would like to try it out as a door alarm switch but I want to make sure I have the correct circuit.

    • Waqas Ahmed says:

      Thank you so much Jason for the compliments and pointing out the corrections needed. Actually, there were some technical issues with the post and circuit diagram was not visible. Please check it now.

Leave a Reply

Your email address will not be published. Required fields are marked *