ESP8266 Peripherals: Mini PIR Motion Sensor


The ESP8266 is all about Internet of Things, right? So lets start sensing something in the real world! What about (human) presence in your apartment? There are various ways to do that but one of the most common type is sensing with pyro electric sensors which also called passive infrared (PIR) sensors (see Wikipedia). The one I am presenting in this post is also a PIR sensor; a really tiny one and with its 3.3V support very suitable for the ESP8266.

PIR Sensor with 3.3V support
PIR Sensor with 3.3V support



  • Working voltage: DC 2.7-12V
  • Static power consumption: I measured between 0.016mA (source detected) and 0.076mA (sensor active)
  • Delay time: when detecting a source the sensor will hold the output high for 2 seconds
  • Sensing range: ≤100 degree cone angle, about 2m, possibly more in friendlier environmentWorking
  • Total size: Approx. 12mm x 25 mm


How to use it with the ESP8266?
Since the Mini PIR sensor can handle 3.3V its output level will be ESP8266 compatible. It only has three pins, one for Vin, GND and Data (output) pin. You can wire it up like this:
Wiring Mini PIR with ESP8266
Wiring Mini PIR with ESP8266


  • 3.3V with Vin (left)
  • D2 with Data (middle)
  • GND with GND (right)

then paste this code to your Arduino IDE and upload it to the connected NodeMCU:

int oldValue = 0;

void setup() {
  // put your setup code here, to run once:
  pinMode(D2, INPUT_PULLUP);


void loop() {
  int value = digitalRead(D2);
  if (value != oldValue) {
    Serial.println("New Value: " + String(value));
    oldValue = value;
    if (value == 1) {


Open the serial console and you should see movement in front of the sensor as output in your serial console.


Where to use?

The fact that there is no need of additional components makes this motion sensor very useful for a series of applications. While not detecting any heat source the sensor consumes 0.076mA and in the two seconds after detection even goes down to 0.016mA. So in theory the sensor alone could run on a 1200mAh battery for nearly two years.  Together with a clever circuit you can put the ESP8266’s CH_EN (chip enable) pin low and send it to an ultra deep sleep (0.5µA!!!) and only wake it up when motion has been detected. Read more in this post over at the ESP8266 forum how it can be done:

The schema looks promising but I haven’t tried it out yet.PIR-ESP8266-Low-Power

Pros and Cons

The low price, small form factor, the simple interface and its ability to handle a wide range of voltages makes it very convenient to use with the ESP8266. The detection range on the other hand seems to be rather short, I had accurate detections within about 2 meters. Nonetheless there are still many applications that you can use this module for…


Where to buy?

Order one now from Banggood




Posted by Daniel Eichhorn

Daniel Eichhorn is a software engineer and an enthusiastic maker. He loves working on projects related to the Internet of Things, electronics, and embedded software. He owns two 3D printers: a Creality Ender 3 V2 and an Elegoo Mars 3. In 2018, he co-founded ThingPulse along with Marcel Stör. Together, they develop IoT hardware and distribute it to various locations around the world.


  1. Where did you find this sensor? The packaging looks similar to the HC-SR505 module but the 505 has working voltage starting at 4.5V. There is another PIR sensor generically identified as PM-8 which can be found on Ebay (search for ‘3.3V mini PIR’ for a selection). It says it has a range up to 5 meters.

Leave a Reply