Component Guide

Input Devices Beginner

HC-SR501 PIR Motion Sensor

Detects movement and triggers alarms, lights, or notifications.

HC-SR501 PIR Motion Sensor

Explain Like I'm 12

PIR sensor is like a guard that watches for movement. When someone walks by, it sends a signal to your ESP32 — perfect for security alarms or automatic lights.

Technical Specifications

Arduino library: Built-in digitalRead

  • Detection range: up to 7 m
  • Operating voltage: 5 V to 20 V
  • Digital output: HIGH when motion detected
  • Adjustable sensitivity and delay

Pinout

  • VCC → 5 V
  • GND → GND
  • OUT → GPIO27

Wiring

Connect each pin as shown in the pinout section above.

Wiring Diagram Wiring diagram for HC-SR501 PIR Motion Sensor

Code Example

Copy into Arduino IDE. Install the library listed above first.

example.ino
#define PIR 27
void setup() { Serial.begin(115200); pinMode(PIR, INPUT); }
void loop() {
  if (digitalRead(PIR) == HIGH) Serial.println("Motion detected!");
  delay(200);
}

Expected Output

Serial Monitor prints "Motion detected!" when someone moves nearby.

Related Projects

FAQ

Downloads

Official manufacturer PDF for teachers and advanced builders.

Datasheet coming soon.