PIR sensor HC-SR501
motion detector
Detects movement of warm bodies (people, animals) up to ~7 m. The white dome is a lens that gathers infrared radiation. For alarms and automatic lights.
Open the course →How it works
A passive infrared (PIR) sensor has two heat-sensitive elements. When a person passes, one element "sees" more heat than the other → difference → OUT goes HIGH for a set time (adjustable 3 s – 5 min). Then it returns LOW. The Sx potentiometer changes sensitivity (distance), Tx how long OUT stays HIGH.
Pins and wiring
| Pin | What it is | Where it connects / why |
|---|---|---|
| VCC | Power | → VIN (5 V). The module has a 3.3 V regulator inside. |
| OUT | Digital output | → GPIO (e.g. 27). The output is 3.3 V — safe for the ESP32. |
| GND | Ground | → GND. |
Specifications
Power4.5 – 20 V
Output3.3 V HIGH / 0 V LOW
Range3 – 7 m, 110°
Hold time3 s – 5 min (Tx pot)
Warm-up~60 s after power-up
JumperH = repeatable trigger, L = single trigger
Tips and typical mistakes
- The first minute after power-up gives false detections — normal, the sensor is stabilising.
- It is sensitive to warm air (radiator, air conditioner) — do not point it at them.
- The jumper on H is better for an alarm — OUT stays HIGH while there is motion.