PIR Motion Sensors

Complete guide to passive infrared motion detection sensors

PIR Motion Sensor

PIR Sensor Overview

PIR (Passive Infrared) sensors detect motion by measuring infrared light radiating from objects in their field of view, typically used to detect human movement.

  • Passive Detection: Doesn't emit energy, only receives IR radiation
  • Human Detection: Specifically tuned for human body heat signatures
  • Adjustable Settings: Sensitivity and time delay can be adjusted
  • Digital Output: Simple HIGH/LOW signal when motion detected
  • Wide Angle: Typically 110° detection cone
  • Low Power: Consumes very little energy
  • Reliable: Few false positives when properly adjusted
  • Works in Darkness: Doesn't require visible light
  • Simple Interface: Easy to connect to microcontrollers
  • Inexpensive: Cost-effective motion detection
  • Security Systems: Intruder detection
  • Automatic Lighting: Motion-activated lights
  • Energy Saving: HVAC and appliance control
  • Smart Home: Presence detection
  • Wildlife Monitoring: Animal movement tracking

Technical Specifications

PIR Sensor Module

Standard HC-SR501 Module

Operating Voltage 5V-20V DC
Output Signal Digital (3.3V TTL)
Detection Range Up to 7 meters
Detection Angle 110°
Time Delay Adjust 5s-300s
Sensitivity Adjust 3m-7m
HC-SR501 Standard

Detection Characteristics

  • Wavelength: 8-14μm (human body IR emission)
  • Trigger Mode:
    • Non-Repeatable: Output LOW until motion stops then HIGH
    • Repeatable: Output HIGH while motion continues
  • Warm-up Time: 30-60 seconds after power on
  • Reset Time: ~3 seconds between detections
  • Temperature Range: -15°C to +70°C

Detection Pattern

PIR Detection Pattern

How PIR Sensors Work

PIR Working Principle

Working Principle

  1. Pyroelectric Sensor: Detects changes in IR radiation
  2. Fresnel Lens: Focuses IR radiation and creates detection zones
  3. Differential Detection: Two sensors compare IR levels
  4. Signal Processing: Filters out background changes
  5. Output Trigger: Digital signal when motion detected

Key Components

  • Pyroelectric Element: Generates charge when exposed to IR
  • Fresnel Lens Array: Expands detection area
  • BISS0001 Chip: Signal processing IC
  • Potentiometers: Adjust time delay and sensitivity
  • Output Indicator LED: Visual detection indicator

Detection Optimization

  • Mounting Height: 2-3 meters for best human detection
  • Angle: Point toward area of interest
  • Environment: Avoid direct sunlight and heat sources
  • Placement: Corner mounting provides best coverage
  • Testing: Walk test to verify coverage

Pinout and Wiring

PIR Sensor Pinout

Standard 3-Pin Module

  1. VCC (5V): Power supply (5V-12V recommended)
  2. OUT: Digital output (HIGH when motion detected)
  3. GND: Ground connection
PIR Sensor Circuit

Module Components

  • PIR Sensor: Pyroelectric detection element
  • Fresnel Lens: Focuses IR radiation
  • BISS0001: Signal processing IC
  • Time Delay Adjust: Sets output duration
  • Sensitivity Adjust: Sets detection range

Typical Wiring Diagram

PIR Wiring Diagram

Important Wiring Notes

  • Power Requirements: 5V-12V (3.3V may work but less reliable)
  • Output Signal: 3.3V TTL compatible with 5V Arduino
  • Warm-up Time: Needs 30-60 seconds to stabilize after power on
  • Current Draw:
    • Quiescent: ~50μA
    • Active: ~1mA
  • Pull-Down Resistor: May need 10KΩ resistor on output

Code Examples

Basic Arduino Example

// Basic PIR Motion Sensor Example
#define PIR_PIN 2

void setup() {
    Serial.begin(9600);
    pinMode(PIR_PIN, INPUT);
    Serial.println("PIR Sensor Warming Up (30-60 seconds)");
    delay(50000); // Warm-up delay
    Serial.println("PIR Sensor Ready");
}

void loop() {
    if(digitalRead(PIR_PIN) == HIGH) {
        Serial.println("Motion detected!");
        delay(1000); // Avoid multiple detections
    }
}

Advanced Example with LED and Buzzer

// PIR with visual/audio feedback
#define PIR_PIN 2
#define LED_PIN 3
#define BUZZER_PIN 4

void setup() {
    pinMode(PIR_PIN, INPUT);
    pinMode(LED_PIN, OUTPUT);
    pinMode(BUZZER_PIN, OUTPUT);
    Serial.begin(9600);
    delay(60000); // 60 second warm-up
}

void loop() {
    if(digitalRead(PIR_PIN) == HIGH) {
        triggerAlarm();
    }
}

void triggerAlarm() {
    Serial.println("ALERT: Motion detected!");
    
    // Flash LED and sound buzzer
    for(int i = 0; i < 5; i++) {
        digitalWrite(LED_PIN, HIGH);
        tone(BUZZER_PIN, 1000);
        delay(200);
        digitalWrite(LED_PIN, LOW);
        noTone(BUZZER_PIN);
        delay(200);
    }
    
    delay(5000); // 5 second cooldown
}

ESP8266 WiFi Motion Alert

// PIR with WiFi notification
#include <ESP8266WiFi.h>
#include <WiFiClient.h>

#define PIR_PIN D2
const char* ssid = "YOUR_SSID";
const char* password = "YOUR_PASSWORD";

WiFiServer server(80);

void setup() {
    Serial.begin(115200);
    pinMode(PIR_PIN, INPUT);
    
    WiFi.begin(ssid, password);
    while(WiFi.status() != WL_CONNECTED) {
        delay(500);
        Serial.print(".");
    }
    
    Serial.println("");
    Serial.println("WiFi connected");
    Serial.println("IP address: ");
    Serial.println(WiFi.localIP());
    
    server.begin();
    delay(60000); // PIR warm-up
}

void loop() {
    if(digitalRead(PIR_PIN) == HIGH) {
        sendNotification();
        delay(10000); // 10 second delay between detections
    }
}

void sendNotification() {
    WiFiClient client;
    if(client.connect("maker.ifttt.com", 80)) {
        String url = "/trigger/motion_detected/with/key/YOUR_KEY";
        client.print("GET " + url + " HTTP/1.1\r\n" +
                     "Host: maker.ifttt.com\r\n" +
                     "Connection: close\r\n\r\n");
        Serial.println("Notification sent");
    }
}

Project Ideas

Security Light

Automatic light that turns on when motion is detected.

PIR LED Strip Relay

Intruder Alarm

Sound alarm and send notification when motion detected.

PIR Buzzer ESP8266

Pet Monitor

Track when your pet enters/leaves certain areas.

PIR LCD SD Card

Energy Saver

Turn off devices when no motion is detected.

PIR Smart Plug Arduino

Visitor Counter

Count people entering/exiting a space.

Dual PIR OLED Counter

Wildlife Camera

Trigger camera when animal motion is detected.

PIR Camera Battery

Advanced Project: Smart Security System

// Components needed:
- Multiple PIR sensors
- ESP32-CAM
- Magnetic door/window sensors
- Siren
- Keypad
- OLED display
- Cloud service

// Features:
1. Multi-zone motion detection
2. Live video capture on alarm
3. Mobile notifications
4. Armed/disarmed states
5. Entry delay
6. Battery backup

// Implementation Tips:
- Use deep sleep for battery operation
- Implement zone-specific responses
- Add two-stage arming (stay/away)
- Create custom alert patterns
- Add remote configuration
- Implement event logging

Best Practices & Tips

Installation

  • Mount 2-3 meters high for best coverage
  • Point toward entry points or area of interest
  • Avoid pointing at heat sources or windows
  • Angle downward slightly (15-30 degrees)
  • Test coverage with walk tests

Configuration

  • Always allow 30-60 second warm-up period
  • Set time delay appropriate for application
  • Adjust sensitivity to avoid false triggers
  • Test with actual movement patterns
  • Mark detection zones for reference

Maintenance

  • Clean lens regularly
  • Check for insect nests
  • Verify detection range periodically
  • Re-calibrate if environment changes
  • Check power connections

Common Mistakes to Avoid

Mistake Consequence Solution
No warm-up time False alarms Always allow 30-60s stabilization
Pointing at heat sources False triggers Avoid vents, heaters, windows
Improper mounting height Reduced detection Mount 2-3m high
Too short time delay Constant triggering Set appropriate delay (30s+)
Dirty lens Reduced sensitivity Clean regularly