PIR Motion Sensor
What is an HC-SR501 PIR Sensor?
A PIR motion sensor detects movement from people, animals, and warm objects by watching changes in infrared radiation. The HC-SR501 module is popular in Arduino security alarms, automatic lights, room-occupancy projects, and low-power wake-up circuits.
Unlike distance sensors, a PIR sensor does not measure range precisely. It reports motion inside a detection cone, usually around 3 to 7 meters depending on the lens, sensitivity setting, temperature contrast, and mounting position.
Key Features
Human Motion Detection
Detects moving warm bodies for alarms, automatic lighting, door triggers, and occupancy sensing.
Adjustable Sensitivity
Onboard potentiometers set detection distance and output hold time without code changes.
Low Current Module
Suitable for battery-assisted projects because the sensor output can wake a sleeping microcontroller.
Wide Fresnel Lens
The dome lens splits the field of view into zones so movement produces a clear changing signal.
Simple Digital Output
Connects to one digital input pin and returns HIGH when motion is detected.
Smart Home Ready
Useful for hallway lights, entry alerts, energy-saving systems, and IoT notifications.
Pin Configuration
VCC
Power input, typically 5V on HC-SR501 modules. Many boards accept 5-12V through the onboard regulator.
OUT
Digital motion output. Goes HIGH during the configured hold time after motion is detected.
GND
Ground reference. Connect to the same ground as Arduino, ESP32, or the external power supply.
How It Works
The Science Behind It
PIR means passive infrared. The sensor contains pyroelectric elements that generate tiny signals when infrared energy changes across the lens zones.
The white Fresnel lens breaks the view into alternating hot and cold zones. When a warm body moves across those zones, the signal changes fast enough for the onboard comparator to trigger a digital output.
Detection Logic:
Stable IR pattern = OUT LOW
Changing IR pattern = OUT HIGH
Hold time = delay potentiometer setting
A PIR sensor detects change, not a stationary person. Mounting angle and temperature contrast matter as much as code.
Wiring Tips & Best Practices
Allow Warm-up Time
Wait 30-60 seconds after power-up before trusting readings; the amplifier needs time to stabilize.
Avoid Heat Sources
Keep the sensor away from heaters, sunlight, AC vents, and windows to reduce false triggers.
Mount Across Motion
Detection is strongest when people move across the lens zones, not directly toward the sensor.
Tune Delay First
Set a short hold time during testing, then increase it once the project logic works.
Use Stable Power
Noisy USB supplies can cause random triggers. Add decoupling near the module for long wires.
Debounce in Code
Ignore repeated triggers for a short lockout period if your alarm or relay chatters.