Blog

HC-SR501 PIR Motion Sensor – Complete Guide

PIR Motion Sensor

HC-SR501 PIR Motion Sensor

Passive Infrared Motion Detection with Adjustable Sensitivity & Delay

PIR stands for ”passive infrared” - the sensor does not emit anything itself, it simply watches for CHANGES in the infrared radiation naturally given off by warm objects within its field of view. The white Fresnel lens dome on top isn't just a cosmetic cover; it splits the sensor's view into multiple distinct zones, so as a warm body like a person moves across those zones, the pyroelectric element underneath sees the IR signal rise and fall repeatedly rather than staying constant - and it's specifically that fluctuation the onboard comparator circuit is watching for, which is why a stationary person can eventually stop triggering it while a moving one reliably does. Two onboard trimmer potentiometers give you real control over the module's behavior: one adjusts sensitivity (effectively the detection range, roughly 3 to 7 meters), and the other sets how long the OUTPUT pin stays HIGH after a trigger (from a few seconds up to several minutes) - while a small 3-pin jumper switches between ”repeatable trigger” mode, where continued motion keeps extending the HIGH period, and ”single trigger” mode, where the output drops LOW after the set delay regardless of continued motion.

3–7m (adjustable)
Range
~120°
Detection Angle
5–200s (adjustable)
Delay

Key features

Adjustable Sensitivity

An onboard potentiometer tunes the detection range from roughly 3m to 7m.

Adjustable Time Delay

A second potentiometer sets how long the output stays HIGH, from seconds to minutes.

Selectable Trigger Mode

A jumper switches between repeatable-trigger and single-trigger operation.

Fresnel Lens

Splits the field of view into zones so motion produces a clear, detectable signal change.

Simple Digital Output

Outputs a plain HIGH/LOW signal - no analog reading or calibration needed.

Low Power Consumption

Draws well under 65mA, making it practical for battery and solar-powered projects.

Technical specifications

Supply Voltage 4.5V – 20V DC
Output Signal 3.3V TTL, HIGH on motion
Detection Range 3m – 7m (adjustable)
Detection Angle ~120°
Delay Time ~5s – 200s (adjustable)
Trigger Modes Repeatable (H) / Single (L), jumper-selectable
Block (Lockout) Time ~2.5s default after each trigger
Operating Current <65mA
Warm-Up Time ~30–60s after power-on before stable

Pinout

PinFunction
VCC 4.5V – 20V power supply
OUT Digital output - HIGH while motion is detected
GND Ground

Applications

Automatic lighting and security lights Intruder alarm systems Occupancy-based smart switches Motion-activated cameras Automatic door and hand-dryer triggers Energy-saving room automation

What's in the box

1x HC-SR501 PIR module with Fresnel lens dome

Downloads

Datasheet (PDF) Arduino Motion-Alarm Example Sketch
🔌
Pin Connections
1 Table
Pin Connections Table 1
BoardSensor PinConnection
HC-SR501VCC/GND/OUT5V / GND / board digital pin
📟
PIR Motion Sensor Detector Module HC-SR501
7 Examples • C/C++ | Boards: Arduino Uno, Arduino Nano, Arduino Mega, ESP32, ESP8266, STM32, Raspberry Pi Pico
PIR Motion Sensor Detector Module HC-SR501 - Arduino Uno
PIR Motion Sensor Detector Module HC-SR501 - Arduino Nano
PIR Motion Sensor Detector Module HC-SR501 - Arduino Mega
PIR Motion Sensor Detector Module HC-SR501 - ESP32
PIR Motion Sensor Detector Module HC-SR501 - ESP8266
PIR Motion Sensor Detector Module HC-SR501 - STM32
PIR Motion Sensor Detector Module HC-SR501 - Raspberry Pi Pico
📄 File: pir_motion_sensor_detector_module_hc-sr501_-_arduino_uno.inoArduino Uno
422 characters
1//ekostra.com
2//electronics store in egypt
3//+201008896258
4
5// Digital pin 3 on Arduino Uno. Let the module settle ~30-60s after power-on before trusting readings.
6#define PIR_PIN 3
7
8void setup() {
9 Serial.begin(115200);
10 pinMode(PIR_PIN, INPUT);
11}
12
13void loop() {
14 if (digitalRead(PIR_PIN) == HIGH) {
15 Serial.println("Motion detected!");
16 delay(1000); // simple debounce so it doesn't spam while triggered
17 }
18}
📄 File: pir_motion_sensor_detector_module_hc-sr501_-_arduino_nano.inoArduino Nano
423 characters
1//ekostra.com
2//electronics store in egypt
3//+201008896258
4
5// Digital pin 3 on Arduino Nano. Let the module settle ~30-60s after power-on before trusting readings.
6#define PIR_PIN 3
7
8void setup() {
9 Serial.begin(115200);
10 pinMode(PIR_PIN, INPUT);
11}
12
13void loop() {
14 if (digitalRead(PIR_PIN) == HIGH) {
15 Serial.println("Motion detected!");
16 delay(1000); // simple debounce so it doesn't spam while triggered
17 }
18}
📄 File: pir_motion_sensor_detector_module_hc-sr501_-_arduino_mega.inoArduino Mega
423 characters
1//ekostra.com
2//electronics store in egypt
3//+201008896258
4
5// Digital pin 3 on Arduino Mega. Let the module settle ~30-60s after power-on before trusting readings.
6#define PIR_PIN 3
7
8void setup() {
9 Serial.begin(115200);
10 pinMode(PIR_PIN, INPUT);
11}
12
13void loop() {
14 if (digitalRead(PIR_PIN) == HIGH) {
15 Serial.println("Motion detected!");
16 delay(1000); // simple debounce so it doesn't spam while triggered
17 }
18}
📄 File: pir_motion_sensor_detector_module_hc-sr501_-_esp32.inoESP32
418 characters
1//ekostra.com
2//electronics store in egypt
3//+201008896258
4
5// Digital pin 13 on ESP32. Let the module settle ~30-60s after power-on before trusting readings.
6#define PIR_PIN 13
7
8void setup() {
9 Serial.begin(115200);
10 pinMode(PIR_PIN, INPUT);
11}
12
13void loop() {
14 if (digitalRead(PIR_PIN) == HIGH) {
15 Serial.println("Motion detected!");
16 delay(1000); // simple debounce so it doesn't spam while triggered
17 }
18}
📄 File: pir_motion_sensor_detector_module_hc-sr501_-_esp8266.inoESP8266
420 characters
1//ekostra.com
2//electronics store in egypt
3//+201008896258
4
5// Digital pin D3 on ESP8266. Let the module settle ~30-60s after power-on before trusting readings.
6#define PIR_PIN D3
7
8void setup() {
9 Serial.begin(115200);
10 pinMode(PIR_PIN, INPUT);
11}
12
13void loop() {
14 if (digitalRead(PIR_PIN) == HIGH) {
15 Serial.println("Motion detected!");
16 delay(1000); // simple debounce so it doesn't spam while triggered
17 }
18}
📄 File: pir_motion_sensor_detector_module_hc-sr501_-_stm32.inoSTM32
420 characters
1//ekostra.com
2//electronics store in egypt
3//+201008896258
4
5// Digital pin PB5 on STM32. Let the module settle ~30-60s after power-on before trusting readings.
6#define PIR_PIN PB5
7
8void setup() {
9 Serial.begin(115200);
10 pinMode(PIR_PIN, INPUT);
11}
12
13void loop() {
14 if (digitalRead(PIR_PIN) == HIGH) {
15 Serial.println("Motion detected!");
16 delay(1000); // simple debounce so it doesn't spam while triggered
17 }
18}
📄 File: pir_motion_sensor_detector_module_hc-sr501_-_raspberry_pi_pico.inoRaspberry Pi Pico
430 characters
1//ekostra.com
2//electronics store in egypt
3//+201008896258
4
5// Digital pin 18 on Raspberry Pi Pico. Let the module settle ~30-60s after power-on before trusting readings.
6#define PIR_PIN 18
7
8void setup() {
9 Serial.begin(115200);
10 pinMode(PIR_PIN, INPUT);
11}
12
13void loop() {
14 if (digitalRead(PIR_PIN) == HIGH) {
15 Serial.println("Motion detected!");
16 delay(1000); // simple debounce so it doesn't spam while triggered
17 }
18}
Classic PIR motion sensor - digital output, adjustable sensitivity/delay via onboard potentiometers.
Give the sensor 30-60 seconds to warm up and stabilize after every power-on before trusting its readings - it commonly produces one or two false triggers during this window as the pyroelectric element settles, so have your code ignore the first several seconds of output. Avoid mounting it near HVAC vents, windows with direct sun, or anything else that causes rapid ambient temperature swings, since those can trigger it even with zero actual motion in the room. Start with both potentiometers roughly centered, then tune sensitivity down if it triggers on distant motion you don't care about, and tune the delay potentiometer to match your application - short for a responsive alarm, long for a hallway light that shouldn't keep flickering off.