Build a Motion Sensor Alarm
A motion sensor alarm detects movement within a protected area and activates an alarm, light or notification. Motion sensors are widely used in home security systems, automatic lighting, industrial automation and smart home applications. This project demonstrates how to build a reliable motion detection system using a Passive Infrared (PIR) sensor and an Arduino or ESP32 microcontroller.
Project Overview
The PIR sensor continuously monitors infrared radiation emitted by people and animals.
When movement is detected, the sensor output changes state. The microcontroller receives this signal and activates a buzzer, siren, relay or notification system.
Additional features such as adjustable sensitivity, alarm delay and Wi-Fi alerts can easily be incorporated.
Project Difficulty
| Item | Value |
|---|---|
| Difficulty | ⭐⭐ Beginner–Intermediate |
| Build Time | 2–4 Hours |
| Supply Voltage | 5 V DC |
| Detection Range | 3–7 metres (Typical) |
| Detection Angle | Approximately 120° |
Main Sections
| Section | Function |
|---|---|
| PIR Sensor | Detects movement using infrared radiation. |
| Microcontroller | Processes the sensor output. |
| Buzzer or Siren | Provides an audible alarm. |
| Relay Module (Optional) | Controls external devices. |
| Status LEDs | Show system status. |
| Power Supply | Powers the complete system. |
Typical Components
| Quantity | Component |
|---|---|
| 1 | Arduino Nano or ESP32 |
| 1 | HC-SR501 PIR Motion Sensor |
| 1 | Piezo Buzzer or 12 V Siren |
| 1 | Relay Module (Optional) |
| 2 | LEDs (Power and Alarm) |
| Several | Resistors and Connecting Wires |
| 1 | 5 V Power Supply |
| 1 | Project Enclosure |
How the PIR Sensor Works
A PIR (Passive Infrared) sensor does not emit any energy. Instead, it detects changes in infrared radiation produced by warm objects such as people and animals.
When a person moves across the sensor's field of view, the infrared energy falling on the sensing elements changes. The PIR module processes this change and generates a digital output signal.
The microcontroller detects this output and activates the required alarm or automation function.
Typical PIR Specifications
| Parameter | Typical Value |
|---|---|
| Operating Voltage | 5–20 V DC |
| Current Consumption | Less than 100 µA (Sensor Element) |
| Detection Distance | 3–7 m |
| Viewing Angle | 110–120° |
| Output | Digital HIGH/LOW |
| Delay Adjustment | Typically 3–300 Seconds |
Applications
- Home security systems.
- Intruder alarms.
- Automatic lighting.
- Smart home automation.
- Office security.
- Garage monitoring.
- Warehouse surveillance.
- Energy-saving lighting control.
Testing
- Verify the power supply voltage.
- Allow the PIR sensor to stabilise for about one minute after power-up.
- Walk slowly across the sensor's field of view.
- Verify the alarm activates.
- Adjust sensitivity if necessary.
- Adjust the delay timer.
- Test detection at different distances.
- Confirm reliable operation over several minutes.
Troubleshooting
| Problem | Possible Cause |
|---|---|
| No motion detected | Incorrect wiring or insufficient warm-up time. |
| False alarms | Heat sources, sunlight or incorrect sensitivity setting. |
| Alarm stays on | Delay time set too long. |
| Short detection range | Poor sensor positioning or obstructed field of view. |
| Unstable operation | Unstable power supply or electrical interference. |
Project Improvements
- Send alerts via Wi-Fi using an ESP32.
- Add SMS or email notifications.
- Include a camera module for image capture.
- Store detection events on a MicroSD card.
- Add battery backup.
- Support multiple PIR sensors.
- Display activity logs on an OLED screen.
- Integrate with Home Assistant using MQTT.
Skills Learned
- PIR sensor operation.
- Digital input programming.
- Alarm system design.
- Microcontroller programming.
- Relay control.
- Home automation.
Safety Notes
- Install the sensor away from heaters, air conditioners and direct sunlight.
- Use relay modules correctly when switching mains-powered equipment.
- Provide adequate protection for outdoor installations.
- Use stable power supplies for reliable operation.
- Test the alarm regularly to ensure dependable performance.
Key Points
- PIR sensors detect changes in infrared radiation caused by moving warm objects.
- Motion sensor alarms are widely used in security and automation.
- Adjustable sensitivity and delay improve system performance.
- ESP32-based designs can send alerts over Wi-Fi.
- A motion sensor project is an excellent introduction to security electronics and smart home technology.