Motion Detector Arrangement

Raspberry Pi – Motion detector alarm using PIR sensor

After a long semester with nearly no time to tinker with the Raspberry Pi, I am back, this time experimenting with the Passive Infra-Red (PIR) Sensor to build a motion detector alarm.

First let me explain briefly the working principle of the PIR sensor. All objects with a temperature above absolute zero (0° K or -273° C)  emit heat energy in the form of radiation.
The PIR sensor detects the heat emitted by a body, more precisely the heat change with respect to the environment. The circuitry of the PIR sensor is quite complex; allowing it to detect only human (sometimes animal) movements, thus being perfect to be used for intruder alarms. With the dome shaped lens, the sensor is able to sense motion in all directions in front of it (180°), the lens converges the radiation to the sensor.

PIR Front (naked)

PIR Front (naked)

PIR Front

PIR Front

PIR Lens

PIR Lens

 

PIR Back

PIR Sensor Back

To build the motion detector alarm, we are going to use the following components:

  • Raspberry Pi 3
  • PIR sensor (cheap)
  • Active Buzzer
  • Red LED
  • NPN transistor (PNP transistor also can be used)
  • 2 x 220Ω resistor
  • Multiple jumper wires
  • Breadboard

Firstly in any project, we need to design the system; draw a schematic diagram. My design is shown below.

Schematic Diagram

Schematic of motion detection alarm

The PIR sensor is powered by 5V supply and is connected to the GPIO to signal if a motion was detected. The PIR also has 2 potentiometers, one is to adjust the delay time and the other for the sensitivity(range).
With the buzzer, we had to use a NPN transistor because it requires a larger current, the NPN transistor amplifies the current. You can also use a PNP transistor but the code will be slightly different.

Note: If you are not used to the Raspberry Pi interface, read the last post about programming LEDs.

The next step is to do the connections of the system, mine shown below.

Motion detector circuit diagram

 

Motion Detector Arrangement

Motion Detector Arrangement

The code used for the alarm is shown below and the programming language used is C.

The only difference in the code when using PNP, the signal argument should be opposite for the BeepPin.

This is a video of me testing out the alarm.

Motion detector alarm, now better with improved #coding #electronic

A video posted by Yashtir Gopee (@yashtir) on

The buzzer rings alternately along with the LED blinking as long as movements are being detected.

To do this project, you could have not used the Raspberry Pi but some calculations and adjustments would be needed to adjust for the power needed by the buzzer.
Further improvement you could do to the project is to add a switch which turns off the alarm therefore making it work like a real intruder alarm.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.