Back to Sensors & Actuators Series

HC-SR501 PIR Motion Sensor

April 10, 2026 Wasil Zafar 7 min read

HC-SR501 deep dive — pyroelectric detection principle, Fresnel lens optics, sensitivity adjustment, trigger modes, complete code, and security applications.

Contents

  1. Working Principle
  2. Electrical Characteristics
  3. Interfacing with MCU
  4. Calibration
  5. Code Example
  6. Real-World Applications
  7. Limitations

Working Principle

The HC-SR501 is a passive infrared (PIR) motion detector based on a pyroelectric sensor element. All warm objects emit infrared radiation (~10 µm wavelength). The sensor contains two pyroelectric elements wired in opposite polarity. When a warm body moves across the sensor's field, it sequentially heats one element then the other, producing a differential voltage pulse that signals motion.

Analogy: Picture two thermometers side by side behind a slotted screen. A person walking past heats one thermometer then the other. The difference between them is your motion signal.

Electrical Characteristics

ParameterValue
Supply Voltage4.5 V – 20 V (on-board 3.3 V regulator)
OutputDigital HIGH (3.3 V) on motion
Detection RangeUp to 7 m (adjustable via potentiometer)
Detection Angle<120° cone (Fresnel lens pattern)
Time Delay0.3 s – 5 min (adjustable via potentiometer)
Trigger ModeSingle trigger (L) / Retriggerable (H)
Warm-up Time~60 seconds after power-on
Current<50 µA (quiescent)

Interfacing with an MCU

The HC-SR501 has just three pins: VCC, OUT, and GND. Output goes HIGH (3.3 V) when motion is detected. Two potentiometers adjust sensitivity (range) and output hold time. A jumper selects single-trigger (L) or retriggerable (H) mode.

Wiring (Arduino): VCC → 5 V, GND → GND, OUT → Digital Pin 2. Use INPUT mode; output is 3.3 V but Arduino reads it as HIGH.

Calibration

The HC-SR501 requires no software calibration, but hardware tuning is essential:

  • Sensitivity pot (CW): Increases detection range from ~3 m to ~7 m.
  • Time-delay pot (CW): Increases output hold time from ~0.3 s to ~5 min.
  • Warm-up period: After power-on, the sensor needs ~60 seconds to stabilise — ignore outputs during this window.
  • Fresnel lens swap: Replace the dome lens with a flat Fresnel for narrower detection patterns.

Code Example

/*
 * HC-SR501 PIR Motion Sensor — Arduino
 * Wiring: OUT → Pin 2, VCC → 5V, GND → GND
 * Allow 60s warm-up after power-on
 */
#define PIR_PIN 2
#define LED_PIN 13

volatile bool motionDetected = false;

void motionISR() {
    motionDetected = true;
}

void setup() {
    Serial.begin(9600);
    pinMode(PIR_PIN, INPUT);
    pinMode(LED_PIN, OUTPUT);
    attachInterrupt(digitalPinToInterrupt(PIR_PIN), motionISR, RISING);
    Serial.println("Warming up PIR sensor (60s)...");
    delay(60000);  /* Wait for sensor stabilisation */
    Serial.println("HC-SR501 Ready");
}

void loop() {
    if (motionDetected) {
        motionDetected = false;
        Serial.println("** MOTION DETECTED **");
        digitalWrite(LED_PIN, HIGH);
        delay(2000);
        digitalWrite(LED_PIN, LOW);
    }
}

Real-World Applications

Smart Home

Smart Lighting & HVAC Occupancy

Office buildings deploy PIR sensors in every room to control lighting and air conditioning based on occupancy. The sensor's ultra-low quiescent current (<50 µA) means battery-powered wireless nodes can run for years. Integrating with a building management system (BMS) reduces energy costs by 20–40%.

Smart BuildingEnergy SavingsOccupancy

Limitations

  • Motion only: Detects moving warm bodies, not stationary people — a seated desk worker may not retrigger.
  • False triggers: Pets, sunlight changes, and convection heat can trigger false alarms.
  • Line of sight: IR radiation does not penetrate glass, acrylic, or walls — place the sensor with a clear path.
  • Dead zone: A 2.5-second blind window after each trigger (in single-trigger mode) can miss rapid events.