Best PIR Sensors for ESP32 and ESP8266 Projects (2026)

Introduction

ESP32 and ESP8266 are popular choices for IoT motion sensors due to their built-in Wi-Fi and low-power capabilities. However, choosing the right PIR sensor for these 3.3V boards requires attention to voltage compatibility and power consumption. This guide covers the best options.

Key Considerations for ESP Boards

1. Voltage Compatibility

ESP32 and ESP8266 GPIO pins are 3.3V tolerant only. 5V output from a PIR sensor can damage the ESP. Options:

  • Use 3.3V-compatible sensors (AM312, Panasonic EKMB, Excelitas PYD)
  • Use voltage divider or level shifter with 5V sensors

2. Power Consumption for Battery Projects

ESP boards in deep sleep draw 5-150µA (ESP32 ~5µA, ESP8266 ~20µA). Adding a PIR sensor with 50µA standby doubles consumption. Ultra-low power sensors (1-6µA) are ideal for battery projects.

3. Wake-on-Motion Capability

ESP32 and ESP8266 can wake from deep sleep using an external interrupt. Choose a PIR sensor that can generate an interrupt on motion detection.

Top PIR Sensors for ESP32/ESP8266

Best Overall: AM312

Price: $2-3
Voltage: 2.7-12V (works at 3.3V)
Output: 3.0V (safe for ESP GPIO)
Standby current: 35µA
Pros: 3.3V compatible, small size (10×8mm), low power
Cons: Fixed 2-second hold time, shorter range (3-5m)
Best for: General ESP projects, battery-powered applications

Connection:
AM312 VCC → ESP 3.3V
AM312 GND → ESP GND
AM312 OUT → ESP GPIO (any)

Best for Battery Life: Panasonic EKMB Series

Price: $8-12
Voltage: 2.3-4.0V (3.3V works)
Output: Open-drain (requires pull-up to 3.3V)
Standby current: 1-6µA
Pros: Ultra-low power, high sensitivity, various lens options
Cons: More expensive, requires external pull-up resistor, SMD or TO-5 package
Best for: Ultra-low power battery projects, long-term deployments

Connection:
EKMB VCC → ESP 3.3V
EKMB GND → ESP GND
EKMB OUT → ESP GPIO (with 10kΩ pull-up to 3.3V)

Best for Deep Sleep Wake-Up: Excelitas PYD 2597

Price: $6-8
Voltage: 1.4-3.6V
Output: 1-wire digital with interrupt
Standby current: 2µA
Pros: Lowest power, 1.4V operation, integrated wake-up mode
Cons: Requires external lens, more complex interface, SMD
Best for: Energy-harvesting, coin-cell battery projects

Connection:
PYD VCC → ESP 3.3V
PYD GND → ESP GND
PYD OUT → ESP GPIO (with 10kΩ pull-up to 3.3V)

Budget Option: HC-SR501 with Voltage Divider

Price: $2-3
Voltage: 4.5-20V (use 5V supply)
Output: 3.3V (most clones) or 5V (check with multimeter)
Standby current: 50-65µA
Pros: Cheap, adjustable sensitivity and hold time
Cons: Higher power, needs level shifting if output is 5V, not 3.3V compatible
Best for: Budget projects, USB-powered (not battery)

Connection with voltage divider (if output is 5V):
HC-SR501 VCC → 5V supply (not ESP 3.3V)
HC-SR501 GND → ESP GND
HC-SR501 OUT → 10kΩ resistor → ESP GPIO
HC-SR501 OUT → 20kΩ resistor → GND (voltage divider)

Comparison Table

2.7-12V

35µA

Direct 3.3V

$2-3

General projects

2.3-4V

1-6µA

Pull-up required

$8-12

Battery projects

1.4-3.6V

2µA

Direct + pull-up

$6-8

Energy harvesting

4.5-20V

50-65µA

Level shifter needed

$2-3

USB-powered

ESP32 Deep Sleep with PIR Wake-Up

Example code for ESP32 deep sleep with AM312 PIR wake-up:

#include <esp_sleep.h>

const int pirPin = 4;

void setup() {
  Serial.begin(115200);
  pinMode(pirPin, INPUT);
  
  // Configure wake-up on PIR HIGH
  esp_sleep_enable_ext0_wakeup((gpio_num_t)pirPin, 1);
  
  Serial.println("Entering deep sleep...");
  esp_deep_sleep_start();
}

void loop() {
  // Not used - ESP32 is in deep sleep
}

For AM312, the output stays HIGH for 2 seconds after detection, which is sufficient to wake the ESP32.

ESP8266 Deep Sleep with PIR Wake-Up

#include <ESP8266WiFi.h>

const int pirPin = D1;  // GPIO5

void setup() {
  Serial.begin(115200);
  pinMode(pirPin, INPUT);
  
  // Configure wake-up on PIR HIGH
  attachInterrupt(digitalPinToInterrupt(pirPin), wakeUp, RISING);
  
  Serial.println("Entering deep sleep...");
  ESP.deepSleep(0);  // Sleep indefinitely until interrupt
}

void wakeUp() {
  // This function runs when PIR triggers
  // ESP8266 will wake and continue execution
}

void loop() {
  // Code after wake runs here
  // ... send notification, etc.
}

Power Budget Calculation

Example: AM312 (35µA) + ESP32 deep sleep (5µA) = 40µA total
2000mAh battery / 0.04mA = 50,000 hours ≈ 5.7 years theoretical

Realistically, with daily transmissions and battery self-discharge, expect 2-3 years.

Conclusion

For most ESP32/ESP8266 projects, the AM312 offers the best balance of price, power consumption, and ease of use. It works directly at 3.3V without level shifting and provides adequate sensitivity for indoor applications. For ultra-low power battery projects, the Panasonic EKMB series (1µA) is worth the extra cost. The HC-SR501 is only recommended for USB-powered projects where power consumption isn’t critical.

Leave a Reply

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

Sensor Voltage Current (standby) ESP Compatibility Price Best For
AM312 Panasonic EKMB Excelitas PYD HC-SR501