Easy Basics: Project 066k ESP8266 ESP-12E module - deep sleep mode

of Acoptex.com in ESP8266 ESP-12

Basics: Project 066k

Project name: ESP8266 ESP-12E module - deep sleep mode

Tags: ESP, ESP8266, WI FI module, ESP-12E, Ai Thinker, AI-Cloud, SOC, GPIO, General Purpose Input Output, System On a Chip, IOT, internet of things, FTDI232, FTDI 232, how to upload sketch, LoLin NODEMCU V3, NODEMCU, V3, Development Board with USB-to-Serial Onboard, NodeMCU DevKit, deep sleep mode

Attachments: sketch

In this project, you need these parts :

1. ESP8266 ESP-12E module with micro USB cable 1pc

2.Arduino IDE ( you can download it from here  )

3.Jumper cables F-M, F-F, M-M


We will learn what is deep sleep and how to use it with ESP8266 ESP-12E module (LoLin NODEMCU V3). 

Understanding the deep sleep

If you made a project with an ESP8266 ESP-12E module (LoLin NODEMCU V3) which is powered from a battery, or if you just connected your ESP8266 ESP-12E module (LoLin NODEMCU V3) to a power bank, after running it for some time you realize the battery/power bank does not last long.

With most of the ESP8266 modules, you can not change the hardware to save power, but you can do it with software. If you use the sleep functions with the ESP8266, it will draw less power and your batteries will last longer. In this project we are going to speak about Deep Sleep with the ESP8266.

Types of Sleep

There are three types of sleep modes: modem sleep, light sleep, and deep sleep.

These modes have different purposes and they should be used in different applications.

Deep sleep

For this project we want that everything will be always off, except the Real Time Clock (RTC) to keep the time on ESP8266. If we use the deep sleep mode, the most efficient power saving option and the ESP8266 chip draws approximately 20uA only.

With deep sleep the 4 steps are in place:

  1. ESP8266 connects to Wi-Fi;
  2. The ESP8266 performs an action (reads a sensor, publishes an MQTT message and so on);
  3. Sleeps for a defined number of microseconds;
  4. Repeats that process over and over.

Other sleep modes

Other sleep modes like the modem sleep and light sleep are helpful if you still need to have your ESP8266 functioning and you want some additional power options. However, if you need some serious power saving, Deep Sleep is the only way to go.

Understanding the ESP8266 ESP-12E WI FI module (LoLin NODEMCU V3)

You can read more about it here.

Signals and connections of the ESP8266 ESP-12E WI FI module (LoLin NODEMCU V3)

TX - transmit pin. GPIO pin

RX  - receive pin.  GPIO pin

3V3 (or 3V or 3.3V) - power supply pin (3-3.6V). 

GND ( or G) - ground pin.

RST - reset pin. Keep it on high (3.3V) for normal operation. Put it on 0V to reset the chip.

EN - Chip enable. Keep it on high (3.3V) for normal operation.

Vin - External power supply 5VDC.

D0-D8 - GPIO (General Purpose Input Output) pins 

D5-D8 - SPI interface

D1-D2– I²C/TWI Interface

SC (or CMD) - (Chip Select) - the pin that the master can use to enable and disable specific devices. GPIO pin

SO (or SDO) - Master In Slave Out (MISO) - SPI communication. The Slave line for sending data to the master. GPIO pin

SK (or CLK) - SCK (Serial Clock) - SPI communication.The clock pulses which synchronize data transmission generated by the master. GPIO pin

S1 (or SD1) - Master Out/Slave In (MOSI). SPI communication. The Master line for sending data to the peripherals. GPIO pin

S2 (or SD2) - GPIO pin

S3 (or SD3) - GPIO pin

VU (or VUSB) - external power 5VDC.

A0 - ADC output.

RSV - reserved


You need to use a wire to connect the RST pin to GPIO 16 which is labeled as D0, in a NodeMCU board. If you look at the NodeMCU pinout, you can see that GPIO 16 is a special pin and it has a WAKE option. The RST pin of the ESP8266 is always HIGH while the ESP8266 is running. However, when the RST pin receives a LOW signal, it restarts the microcontroller. If you set a Deep Sleep timer with the ESP8266, once the timer ends, GPIO 16 sends a LOW signal. That means that GPIO 16 when connected to RST pin can wake up the ESP8266 every time the timer ends.

Step by Step instruction

1. Adding ESP8266 platform to Arduino IDE

the Arduino environment has to be set up to make it compatible with the 
ESP-01 module. It is required to have Arduino version 1.6.4 or higher in order to install the ESP8266’s platform packages.

The Arduino environment has to be set up to make it compatible with the ESP8266 ESP-01 module. It is required to have Arduino IDE version 1.6.4 or higher in order to install the ESP8266’s platform packages.

  1. Open Arduino IDE. 
  2. Open the Preferences window from the Arduino IDE. Go to File -> Preferences.
  3. Enter http://arduino.esp8266.com/stable/package_esp8266com_index.json into Additional Board Manager URLs field and click the “OK” button. If you already have a URL in there, and want to keep it, you can separate multiple URLs by placing a comma between them. (Arduino 1.6.5 added an expanded text box, separate links in here by line.)

  4. Open Boards manager. Go to Tools -> Board -> Boards Manager…

  5. There should be a couple new entries in addition to the standard Arduino boards. Look for esp8266. or scroll down to the ESP8266 entry (usually at the bottom). Select the ESP8266 entry. When you click it an install option will appear. Select the latest version and click install
  6. The board definitions and tools for the ESP8266 include a whole new set of gcc, g++, and other reasonably large, compiled binaries, so it may take a few minutes to download and install (the archived file is ~110MB). Once the installation has completed, an Arduino-blue “INSTALLED” will appear next to the entry.

2. Uploading sketch to ESP8266 ESP-12E module 

 If you’re using an ESP-12E NodeMCU Kit, uploading the sketch is very simple, since it has built-in programmer. 

Before use ESP8266 ESP-12E WI FI module (LoLin NODEMCU V3), you need to download the manufacture's driver (CH340)  for this chip and install it in your PC. Here is the link. See the description of driver installation package below: CH340 / CH341 USB to serial WINDOWS driver installation package that supports 32/64 bit Windows 10 / 8.1 / 8/7 / VISTA / XP, SERVER 2016/2012/2008/2003, 2000 / ME / 98, through Microsoft digital signature authentication, support USB to 3-wire and 9-wire serial port, with the product release To the end user. Applicable scope: CH340G, CH340C, CH340B, CH340E, CH340T, CH340R, CH341A, CH341T, CH341H chips.

If you have CP2102 chip then  you need to download the manufacture's driver for this chip and install it in your PC. Driver for Mac, Windows, Linux or more.. 

  1. Do wiring.
  2. Open Arduino IDE.
  3. Plug your ESP8266 ESP-12E module into your PC USB port.
  4. Choose your NodeMCU board. Go to Tools -> Board -> NodeMCU 1.0 (ESP-12E Module)
  5. Select the correct com port.
  6. Verify and upload the sketch to your ESP8266 ESP-12E module. AT commands will not work after that. You need to Flash the firmware to enable them again.
  7. Open Serial monitor at baud rate of 9600 bps.
  8. The message will be printed in the serial monitor, then the ESP8266 goes to sleep for 30 seconds, and repeats. The deepSleep() time is specified in microseconds (ms).


We have learnt what is deep sleep and how to use it with ESP8266 ESP-12E module (LoLin NODEMCU V3). 


  • No libraries required for this project.


  • You can find it on the begining of this project

Other projects of Acoptex.com
Easy Merry Xmas to everyone of Acoptex.com, Not selected 24-12-2019

« Go back to category
Is this project fake? Report it!   
Recommend to a friend
Published at 05-06-2018
Viewed: 2499 times