4DVolt

HC-SR501 PIR sensor: pinout and wiring

The PIR sensor detects the movement of people and animals through changes in infrared heat. See the pinout, the two module adjustments, how to wire it to an Arduino and test the output behavior in the simulator.

HC-SR501 PIR motion sensor
HC-SR501 PIR

Specifications

Measures
Presence (motion)
Supply
5 V to 20 V (on-board regulator)
Output
3.3 V digital (HIGH on motion)
Range
3 to 7 m (adjustable)
Angle
≈ 110°
Time HIGH
≈ 0.3 s to 5 min (adjustable)
Warm-up
≈ 30 to 60 s at power-on
Current
≈ 65 µA idle

Pinout

With the white dome (Fresnel lens) facing up and the pins toward you, the order is usually VCC, OUT and GND, but it varies: check the silkscreen under the board.

HC-SR501 (3 pins)

1 VCC Power supply, 5 V
2 OUT Digital output: HIGH when motion is detected
3 GND Ground

PIR sensor simulator

Simulate motion in front of the sensor and see how long the output stays HIGH.

Trigger mode
OUT output
Time left

In repeat trigger mode every new motion restarts the delay count. In single trigger mode the output returns to LOW at the end of the delay even if motion continues.

How to wire it

Connect VCC to 5 V and GND to ground. Connect OUT to a digital input pin, for example D2 on the Arduino Uno. No resistor needed.

After power-up the sensor takes 30 to 60 seconds to calibrate. During this time the output may trigger on its own: ignore the readings.

The module has two potentiometers: one sets the sensitivity (range) and the other the time the output stays HIGH after a detection. Turn both to the middle as a starting point.

The mode jumper chooses between repeat trigger (the output stays HIGH while there is motion) and single trigger (it returns to LOW even with continuous motion).

The output is 3.3 V, which Arduino and ESP32 read as HIGH. To drive a relay or lamp use a transistor or a relay module, not the pin directly.

Example code (Arduino)

Sketch that turns on the board LED (pin 13) while there is motion and prints a message to the serial monitor.

#define PIR_PIN 2
#define LED_PIN 13

void setup() {
  Serial.begin(9600);
  pinMode(PIR_PIN, INPUT);
  pinMode(LED_PIN, OUTPUT);
  delay(30000);                 // sensor warm-up
}

void loop() {
  bool motion = digitalRead(PIR_PIN) == HIGH;
  digitalWrite(LED_PIN, motion);
  if (motion) {
    Serial.println("Motion detected");
    delay(500);
  }
}

Common mistakes

  • Reading the sensor in the first 30 seconds: it is still calibrating and triggers for no reason.
  • Pointing the PIR at a window, heater or air conditioner: heat changes cause false triggers.
  • Expecting it to detect a person standing still: it only reacts to motion, so a short HIGH time "forgets" someone who does not move.
  • Driving a relay or load straight from OUT: the pin cannot supply that current.
  • Mixing up the pin order: on some modules VCC and GND are swapped and the sensor burns out.

Always check the manufacturer's datasheet for your exact model: pin order can vary between modules.

Frequently asked questions

How does a PIR sensor work?

The pyroelectric element measures ambient infrared. When a heat source such as a person moves from one lens segment to another, the reading changes and the output goes HIGH.

What is the HC-SR501 delay time?

It is how long the output stays HIGH after detecting motion. It ranges from about 0.3 seconds to 5 minutes, set with the potentiometer.

Does the PIR work with an ESP32?

Yes. The 3.3 V output is compatible. Power VCC with 5 V and connect OUT to an input GPIO.

Why does the PIR trigger by itself?

Usually because of the missing warm-up, an unstable power supply, or heat sources and drafts near the sensor.

Other components