ESP8266

Wake up ESP using PIR

ESP 8266 chip

The ESP is a low-cost MCU chip, produced by Espressif Systems. ESP chips are energy-efficient consume very little energy. The power-saving architecture features three modes of operation: modern sleep, light sleep, and deep sleep mode. This allows battery-powered designs to run longer.

esp8266 sleep mode comparision

In deep sleep mode, CPUs, most of the RAM, and all the digital peripherals are turned off.

Wakeup from deep and light sleep modes can be done using several sources. In this article we will see how to wakeup ESP8266 in Wemos D1 mini v2 from deep sleep using PIR Sensor interrupt.

Activate deep sleep mode (Wemos D1 mini v2)

The system cannot go to deep sleep mode automatically. Users can call the interface function system_deep_sleep. In this tutorial we are going to use Arduino programming to make the Wemos D1 to go to deep sleep mode. Learn more ...

ESP.deepSleep(microseconds, mode)
will put the chip into deep sleep. mode is one of WAKE_RF_DEFAULT, WAKE_RFCAL, WAKE_NO_RFCAL, WAKE_RF_DISABLED. Second argument is optional. So, ESP.deepSleep(60*1000000) wake up the module every 1 minute.

Note: To wake up the ESP8266 after a certain microseconds, make sure RST and D0 are connected. (After uploading the code).

ESP Deep sleep long time:

ESP.deepSleep(0)
ESP.deepsleep(0) suspends the module until it is woken up by a spike on the RST pin. So this is where we are going to use PIR sensor to produce spikes in RST pin (ESP) based on motiion detection and wake up the wemos D1 mini from Deep sleep.

Schematics

PIR esp wake up schematics

Diagram drawn referening stackoverflow and diyprojects

Components used:
  1. 2.2M ohm resistor
  2. 10uf capacitor
  3. 1k ohm, 10k ohm resistor
  4. BC547 transistor
  5. Diode IN4007
  6. Panasonic PIR Motion Sensor [EKMC1603111] Panasonic PIR Motion Sensor [EKMC1603111]

Connection Diagram

PIR, Wemos connection for wake up ESP use case

Capacitor is used to prevent multiple resets. The signal sent from the PIR sensor charges the capacitor and power the base of transistor. Residual energy is removed via the resistor connected parallely to the capacitor.

Test results

Current cosumption when the ESP 8266 is ON and working normally. 120 mA (approx) current is consumed.

140mA ESP normal mode

Current cosumption when the ESP 8266 is in Deep sleep mode. 50 mA (approx) current is consumed.

140mA ESP deep sleep mode

 Current cosumption is still very high, As per esp doc ~20 micro amps, Since i have used Wemos D1 Mini and i have conected the PIR Sensor which will be always active might be the reason for 50 mA consumption.