A standard PIR motion sensor module outputs a simple digital HIGH signal (either 3.3V or 5V, depending on the model) when it detects changes in infrared radiation from a moving warm body. No analog-to-digital conversion or complex spatial scaling math is required for basic presence detection; the raw reading is a binary 1 (motion) or 0 (clear). However, because these modules cannot natively measure distance or speed, translating the output into physical units requires mapping the HIGH pulse duration to time-based presence metrics using the module's onboard RC timing circuitry.
The Pyroelectric Sensing Principle
Passive Infrared (PIR) sensors rely on the pyroelectric effect, where certain crystalline materials (like lithium tantalate) generate a temporary surface voltage when their temperature changes due to incident infrared radiation. The sensor element inside the metal can actually contains two distinct slots wired in a differential configuration. When a warm body enters the field of view, it intercepts one half of the sensor first, causing a positive differential voltage spike, followed by a negative spike as the body moves across the second half. This differential setup is what allows the sensor to ignore gradual ambient temperature shifts and only trigger on localized movement.
The white plastic dome covering the sensor is a Fresnel lens, which serves two critical functions: it concentrates diffuse infrared energy onto the tiny sensor element, and it fractures the sensor's field of view into a grid of discrete detection zones. Motion is only registered when a heat source physically crosses the boundary between these alternating zones, creating the rapid differential voltage spike that the onboard comparator chip (typically a BISS0001) amplifies and shapes into a clean digital logic pulse.
Hardware Pinout and Wiring Specifications
When selecting a PIR motion sensor module for a microcontroller project, the supply voltage and logic output levels are your primary constraints. The ubiquitous HC-SR501 is cheap and adjustable but requires 5V and outputs 5V logic, which can damage 3.3V ESP32 GPIO pins without a level shifter. The miniature AM312 is native 3.3V and ideal for modern low-power microcontrollers.
| Specification | HC-SR501 (Standard) | AM312 (Miniature) | Panasonic EKMB (Industrial) |
|---|---|---|---|
| Supply Voltage (VCC) | 4.5V - 20V DC | 2.7V - 3.6V DC | 3.0V - 6.0V DC |
| Logic Output (OUT) | ~VCC (Typically 5V) | ~VCC (3.3V) | Open Drain / Digital |
| Quiescent Current | ~50 µA | ~12 µA | ~1 µA |
| Adjustability | Pots for Delay/Sensitivity | Fixed (No pots) | Fixed / I2C variants |
| Typical Cost (2026) | $1.50 - $2.50 | $1.80 - $3.00 | $12.00 - $18.00 |
If you must use the 5V HC-SR501 with an ESP32, do not connect the OUT pin directly to a standard GPIO. Use a simple voltage divider (e.g., a 2kΩ and 3.3kΩ resistor) to step the 5V signal down to a safe 3.0V, or switch to the AM312 module which natively outputs 3.3V logic. See the Espressif GPIO documentation for absolute maximum pin ratings.
Output Signal Logic and Timing Math
A common misconception among beginners is that a PIR sensor outputs an analog voltage proportional to the distance of the detected object. This is false. The raw reading is a strict boolean digital state ($S \in \{0, 1\}$). Therefore, the mathematical translation from raw signal to physical unit is a time-domain integration, not a spatial one. We measure the duration of the presence event.
On modules like the HC-SR501, the output HIGH duration is controlled by an onboard RC (resistor-capacitor) timing circuit tied to the BISS0001 chip. The physical unit of time delay ($T_{delay}$) is calculated by the potentiometer setting:
T_delay = R_pot * C_timing * K
Where R_pot is the resistance of the delay potentiometer (typically 0Ω to 1MΩ), C_timing is the fixed onboard capacitor (often 104 or 0.1µF), and K is the internal timing constant of the BISS0001 chip. In practice, turning the delay potentiometer fully counter-clockwise yields a minimum $T_{delay}$ of approximately 0.3 seconds, while fully clockwise yields roughly 15 to 18 seconds. For precise timing in your code, you should ignore the potentiometer's physical delay and handle the timing state-machine in software.
// ESP32 / Arduino PIR State Machine with Software Debounce
const int PIR_PIN = 14;
unsigned long lastTriggerTime = 0;
const unsigned long DEBOUNCE_MS = 2000; // 2-second software lockout
void setup() {
Serial.begin(115200);
pinMode(PIR_PIN, INPUT);
Serial.println("Calibrating PIR baseline...");
delay(30000); // Mandatory 30s burn-in for BISS0001 ambient averaging
Serial.println("Ready.");
}
void loop() {
int pirState = digitalRead(PIR_PIN);
unsigned long currentTime = millis();
if (pirState == HIGH && (currentTime - lastTriggerTime > DEBOUNCE_MS)) {
lastTriggerTime = currentTime;
Serial.printf("Motion detected at %lu ms\n", currentTime);
// Trigger physical unit action (e.g., log timestamp, turn on relay)
}
}
Common Interference Sources and Calibration
Because PIR sensors detect minute changes in thermal radiation, they are highly susceptible to environmental interference. The most common sources of false triggers include:
- Thermal Drafts: HVAC vents, space heaters, or even a sudden draft from an opening door can shift the ambient temperature across the Fresnel lens zones fast enough to trip the comparator.
- RF Interference: The high-gain WiFi and Bluetooth antennas on an ESP32 can inject RF noise directly into the high-impedance analog front-end of the PIR module if mounted within 2 inches of the sensor can. Always separate the antenna from the PIR dome.
- Direct Sunlight and Incandescent Bulbs: Sunlight contains massive amounts of IR. While the Fresnel lens filters some of it, direct morning sun sweeping across the sensor will blind the pyroelectric element and cause continuous false triggering.
Calibration (The Burn-In Period): When power is first applied, the BISS0001 chip must establish a baseline average of the ambient infrared environment. This requires a stabilization period of 30 to 60 seconds. If your code reads the sensor during this boot window, you will get erratic, continuous HIGH signals. Always implement a blocking delay or a non-blocking boot-state machine that ignores sensor inputs for the first minute of operation. For deeper circuit theory, refer to the Adafruit PIR Sensor Guide.
PIR Motion Sensor Module FAQ
Why is my PIR motion sensor module giving false triggers?
False triggers are almost always caused by environmental thermal shifts or electrical noise. First, check your physical placement: ensure the sensor is not facing an AC vent, a window with direct sunlight, or a heat-generating appliance. Second, check your wiring. If you are using an ESP32 or Arduino with long, unshielded jumper wires running parallel to mains AC wiring or high-current DC motor lines, inductive coupling will inject noise into the PIR's OUT line. Add a 10kΩ pull-down resistor between the OUT pin and GND at the microcontroller end to stiffen the logic line against floating noise.
Can a PIR motion sensor module detect motion through glass?
No. Standard window glass is completely opaque to the long-wave infrared radiation (typically 8 to 14 micrometers) that human bodies emit. The IR energy will heat the glass itself, but it will not pass through to the pyroelectric element. If you need to detect motion through a physical barrier, you must use a microwave radar sensor (like the RCWL-0516) or an ultrasonic module, as those wavelengths easily penetrate glass and drywall.
What is the difference between the H and L trigger modes on the HC-SR501?
The HC-SR501 features a three-pin jumper block that selects between 'H' (Retriggerable) and 'L' (Non-Retriggerable) modes. In H mode, the output stays HIGH as long as motion is continuously detected; every new movement resets the internal timer, extending the HIGH pulse. This is the default and best mode for lighting control. In L mode, the output goes HIGH for the set delay time and then immediately goes LOW, regardless of whether motion is still present. It will not trigger again until the delay time expires and a new 'clear' cycle completes. L mode is rarely used but is helpful for strict sequential timing circuits where overlapping triggers would break the logic.






