Very DeepSleep and energy saving on ESP8266 – Part 6: Power DOWN/UP

The easiest way to save power on an ESP8266 is in fact to switch it OFF when not needed and Switch it ON when needed. A typical example of that is a notifier that mail has been delivered or a door has been opened. Opening a mailbox or opening/closing a door activates a Switch that connects the Vcc to 3V3 and the ESP8266 boots up and does its thing. This seems ideal for the ESP8266-01 that does not have gpio16 broken out and therefore is hard to use in regular deep sleep.
This concept will not work though if the switch prematurely is deactivated and the ESP8266 has not finished its job yet. You need some way to keep the ESP running til it’s job is finished and this means it needs to maintain power and thus the regular ‘deep sleep’ seems the only option.

In deep sleep the current consumption is about 20uA. That is not much but it can be brought down even further to 3uA. For this we do not use the regular deep sleep but we will power down the ESP8266 by pulling the CH_PD (=chip power down) pin LOW to Power it down whereas a Switch (or a HIGH output from a sensor) will Power the ESP8266 up and a gpio pin is used to keep it powered up as long as necessary. This is according to an idea by ‘barnabybear’.

The hardware needed looks as follows:


The workings are like this:
When the switch closes, the CH_PD pin as well as GPIO0 and GPIO2 are taken HIGH and the ESP8266 powers up. Once booted, GPIO0 should be set to HIGH in the software so the CH_PD pin remains HIGH, even when the switch is opening again. The ESP8266 does what it needs to do and when it is done the program sets GPUIO0 LOW and the chip powers down. GPIO2 is directly connected to the Switch, or to a sensor so it can always read the state of the switch or sensor.

The program looks like this:

void setup(){
pinMode(0,OUTPUT);
digitalWrite(0,HIGH);
pinMode(2,INPUT); //not necessary, depending what you want to do with it
}
void loop() {
//do stuff
digitalWrite(0,LOW);
ESP.deepsleep(0);//not necessary
//ESP.deepsleepinstant(0);// or use this one
}

Strictly speaking the line ESP.deepsleep(0); is not necessary. It is just there to put the ESP in deepsleep in case the switch remains activated.

There is a caveat however. This technique requires the ESP8266 module to NOT already have an onboard pull up resistor for the CH_PD.
The original ESP8266-01 is OK, However, the ESP8266-01S has built in resistors.
Modules without internal pullups: ESP-01, ESP-07, ESP-12E, ESP-12F, ESP-12N Modules with internal pullups: ESP-01S, ESP-07S, ESP-12S.

In a follow up I will describe how to cut off power to an ESP8266 completely

Part 1 -DeepSleep General
Part 2 -DeepSleep HTTP publishing
Part 3 -DeepSleep MQTT Publishing
Part 4 -DeepSleep MQTT Subscribing
Part 5 -Deepsleep ESP-NOW
Part 6 – Power Down

Advertisement