Component guide · Beginner · 3 min read
PIR Motion Sensor (HC-SR501)

How It Works and How to Tune It
By Geekobot Learning Team · Updated 24 Oct 2026
On this page
A PIR (passive infrared) sensor detects movement of warm bodies by sensing changes in infrared heat across its field of view. The common HC-SR501 runs on 4.5 to 20 V, sees up to about 7 m across roughly 110 degrees, and outputs a 3.3 V high signal when it detects motion, so it connects directly to Arduino, ESP32 or Raspberry Pi pins.
Key specs at a glance
- Supply
- 4.5 to 20 V DC (HC-SR501); 2.7 to 12 V (AM312 mini)
- Output
- 3.3 V high when motion is detected, 0 V otherwise
- Range
- About 3 to 7 m, adjustable
- Field of view
- About 110 degrees cone
- Hold time
- About 3 s to 5 min, adjustable
- Warm-up
- 30 to 60 s after power-on
- Standby current
- About 50 µA (HC-SR501)
How a PIR sensor detects motion
The sensor inside has two infrared-sensitive halves wired against each other. When the room is still, both halves see the same heat and cancel out. When a person walks past, one half sees their body heat before the other, producing a change that the onboard BISS0001 chip turns into a clean digital pulse. The white Fresnel dome focuses heat from many zones onto the sensor.
Because it detects change, a PIR sensor sees people walking but can lose someone sitting very still. For presence detection, combine it with a microwave radar module such as the RCWL-0516 or an mmWave sensor.
HC-SR501 adjustments: the two pots and the jumper
| Control | What it does | Tip |
|---|---|---|
| Sensitivity pot (Sx) | Sets detection range, about 3 to 7 m | Turn clockwise for more range |
| Time-delay pot (Tx) | How long OUT stays high, about 3 s to 5 min | Set fully anticlockwise and handle timing in code |
| Jumper H (repeat trigger) | Stays high while motion continues | Best for lights |
| Jumper L (single trigger) | One pulse per detection, then a short lock-out | Best for counting events |
- Sensitivity pot (Sx)
- What it does:
- Sets detection range, about 3 to 7 m
- Tip:
- Turn clockwise for more range
- Time-delay pot (Tx)
- What it does:
- How long OUT stays high, about 3 s to 5 min
- Tip:
- Set fully anticlockwise and handle timing in code
- Jumper H (repeat trigger)
- What it does:
- Stays high while motion continues
- Tip:
- Best for lights
- Jumper L (single trigger)
- What it does:
- One pulse per detection, then a short lock-out
- Tip:
- Best for counting events
Wiring a PIR sensor
to 5 V (the module's regulator drops it to 3.3 V internally).
to any digital input. It is 3.3 V, safe for ESP32, Pico and Raspberry Pi.
to ground.
To switch a lamp, have the microcontroller drive a relay module rather than connecting the PIR to mains equipment.
const int PIR = 2;
const int LED = 13;
void setup() {
pinMode(PIR, INPUT);
pinMode(LED, OUTPUT);
Serial.begin(9600);
delay(30000); // let the sensor warm up
Serial.println("Ready");
}
void loop() {
if (digitalRead(PIR) == HIGH) {
digitalWrite(LED, HIGH);
Serial.println("Motion!");
} else {
digitalWrite(LED, LOW);
}
}Stopping false triggers
- Keep the sensor away from heaters, AC vents, windows in direct sun and moving curtains.
- Give it 30 to 60 seconds to settle after power-up and ignore output during that time.
- On ESP32 builds, mount the PIR a few centimetres from the antenna; strong Wi-Fi transmission can trigger some modules.
- Use a clean supply. Ripple from cheap adapters is a common cause of random detections.
Common mistakes to avoid
- Expecting it to detect a person who is sitting still.
- Reading the output before the warm-up period has finished.
- Pointing it through glass; glass blocks the infrared it needs.
- Leaving the time-delay pot at maximum and thinking the sensor is stuck on.
- Wiring by photo instead of by label. Pin order varies between makers, so lift the dome gently and read the VCC, OUT and GND markings.
Frequently asked questions
What is the range of a PIR sensor?
The HC-SR501 detects up to about 7 m at maximum sensitivity across a cone of roughly 110 degrees. Mini sensors such as the AM312 reach about 3 to 5 m.
Can a PIR sensor detect through walls or glass?
No. PIR sensors need a direct line of sight; glass and walls block the far-infrared heat they sense.
Does a PIR sensor work in the dark?
Yes. It senses body heat, not visible light, so it works the same day or night.
Can I connect a PIR sensor directly to an ESP32?
Yes. The HC-SR501 output is 3.3 V, so it connects directly to any ESP32 GPIO. Power the module from 5 V.
Why does my PIR sensor stay on all the time?
Usually the time-delay pot is turned up, the jumper is in repeat mode with constant movement in view, or a heat source is in the field. Turn the delay fully anticlockwise and test in a still room.
Parts for this guide
- ₹74View
Terms in this guide
Projects that use it
Put this into practice: 57 step-by-step builds in our project library use parts from this guide.
Keep learning
Sources
- HC-SR501 PIR motion detector datasheet (module documentation)
- BISS0001 micro-power PIR motion detector IC datasheet
Written by the Geekobot team from manufacturer datasheets. Always check the datasheet for the exact part and variant you buy.

