RPI Security System

Function of RPI Security Alarm

In this instructable you will learn how to make an fully functioning night time alarm system. If the system detects an intruder it will immediately print out "INTRUDER" on your monitor as well as making a loud noise from the alarm. The leds will also flash in a pattern along with the alarm.

Step 1: Materials Needed

Step 2: Procedure

Procedure:

  1. First place power and ground both your rails
  2. Place your 330 resistors at the bottom of the bread board starting at the ground rail to any rail on the bread board
  3. Then place your leds next to your resistor. The short leg goes directly to the right of the resistor if your resistors are placed on the left side of the bread board.
  4. The long leg of led goes anywhere you want but make sure there all in different rails
  5. Connect jumper wires to the long led of your led
  6. Connect jumper wires to any gpio pins
  7. Place buzzer above the resistors with the short leg going in the ground rail
  8. Connect a jumper wire to the buzzer and then into a gpio pin
  9. Now connect the ldr into a power rail and a rail on the bread board
  10. Connect the short leg of the capacitor to the gound rail and the long leg to the right of the ldr
  11. Connect a jumper wire to the left of the ldr and then into a gpio ping
  12. Finally connect three male to female wires onto the motion sensor
  13. Connect each one of the male to female wires to ground, 5v and gpio respectively making sure each is connected to the right end of the motion sensor

Step 3: Code Procedure

Code ProcedureL

Make sure you are using python 3 as this code won't work on any other software.

First we must import the right things

from gpiozero import LED, Buzzer, LightSensor, MotionSensor,

from time import sleep

Now we have to define our electrical components. The number at the end should be the number of the gpio port you connected to with your jumper wire. For the code below you must replace the number with your respective gpio port.

Light1 = LED(21)

Light2 = LED(20)

Light3 = LED(12)

Light4 = LED(16)

alarm = Buzzer(19)

ldr = LightSensor (13,5,1,0.1)

pir = MotionSensor(24)

Now it's time to right the juicy part of the code.

while True:

if ldr.light_detected and pir.motion_detected:

print("safe")

light1.off()

light2.off()

light3.off()

light4.off()

else:

ldr.when_dark and pir.motion_detected

print ("INTRUDER INTRUDER INTRUDER INTRUDER")

alarm.on()

light1.on()

sleep(0.1)

light1.off()

light2.on()

sleep(0.1)

light2.off()

light3.on()

sleep(0.1)

light3.off()

light4.on()

sleep(0.1)

light4.off()

This is what the code will look like complete

from gpiozero import LED, Buzzer, LightSensor, MotionSensor,

from time import sleep

light1 = LED(21)

light2 = LED(20)

light3 = LED(12)

light4 = LED(16)

alarm = Buzzer(19)

ldr = LightSensor (13,5,1,0.1)

pir = MotionSensor(24)

while True:

if ldr.light_detected and pir.motion_detected:

print("safe")

light1.off()

light2.off()

light3.off()

light4.off()

else:

ldr.when_dark and pir.motion_detected

print ("INTRUDER INTRUDER INTRUDER INTRUDER")

alarm.on()

light1.on()

sleep(0.1)

light1.off()

light2.on()

sleep(0.1)

light2.off()

light3.on()

sleep(0.1)

light3.off()

light4.on()

sleep(0.1)

light4.off()

Now run the code and the module will display your text

Step 4: Final Product

Finally, this is what the system should look like completed:

Share

    Recommendations

    • Paper Contest

      Paper Contest
    • Faux-Real Contest

      Faux-Real Contest
    • Epilog X Contest

      Epilog X Contest

    Discussions

    0
    None

    Nice design. I have been thinking about making a system like this. Thanks for the tutorial.