Home‎ > ‎Home Alarm System project‎ > ‎

Siren Project


In this project I will show you how to add a siren to the alarm system you have already built. I’ve chosen a 2,500 Hz buzzer that gives a nasty shrill but won’t wake the neighbors while you test your system - although you might want to warn your family you are about to make some noise! Once built you can upgrade to a standard alarm siren.

How it works 

The siren will sound when the alarm is triggered. The siren will silence when the zone is reset using the alarm dashboard or after a predefined time-out.

What you need

    All parts can be purchased from the PrivateEyePi Store
  • 1 x 1kOhm resistor. This is optional. The buzzer’s volume can be adjusted by using different resistors. No resister is full volume and quite deafening from close range.
  • 1 x Active buzzer 2,500Hz 3-5V
  • 1 X PN2222A Switching Bipolar Transistor 40V/.6A or 600mA
  • 1 X Model A or B Raspberry Pi, power supply, HD card, screen, keyboard, network etc… Raspbian Wheezy OS
  • 1 X Solderless breadboard
  • 1 X Male to male jumper cable
  • 3 X Female to male jumper cable
Electronics

As per Figure 1 You will be using a transistor to switch the siren on and off. You can also use a relay but I have chosen the PN222A because it is my “go to” Raspberry Pi switch. It can handle switching a DC current of up to 40V and 600mA. This is more than enough for most Raspberry Pi projects. A transistor is very useful for switching. It has three pins. The two outer pins are called the emitter and collector, and the middle pin is called the base. How it works is when a voltage if supplied to the base (middle pin) then it allows current to flow between the emitter to the collector. 

Word of caution: do not use this transistor to switch high voltage AC current.

When and if, you choose to buy an externally powered alarm system siren, make sure that you check the voltage and the current (amps). You want to look for a siren that is under 40V DC and .6A or 600mA. You will need to have an external  power supply. Do not use the Raspberry Pi power to supply a current to the alarm system siren.

In this project we will use the buzzer which can be powered by the Rpi 3V power supply. 

Figure 1 - Solderless breadboard diagram for the PrivateEyePi siren


Software
If you have not already set up the alarm system, you should do this first and then return to this step.


Edit the globals.py file:

  cd /home/pi/pep
  sudo nano globals.py

As per Figure 2 set the UseSiren variable to TRUE and configure the pin number that the siren is connected to. This is the pin number not the GPIO number (the pin numbers are 1-32 for each of the Rpi GPIO pins). See this diagram for more details on pin numbers. The default siren pin number is 11, but you can change it to any other free GPIO pin.
Figure 2 - Siren settings in the alarm.py file

Save the file by typing CTRL-X Y ENTER

Start up the alarm by typing:

Code:

sudo python alarm.py

If you automated you alarm then you should kill the background process and let the cron job restart it for you. You can kill the background process by typing:

Code:

ps ax

Then look for alarm.py in the process list and make not of the process number. Kill the process by typing:

Code:

sudo kill [processnumber]


Where [processnumber] is the number you made a note of from the “ps ax” command.

If you have not already automated the alarm so it restarts itself whenever you restart the Raspberry Pi or whenever the program stops running then follow this tutorial.

So now you should be back up and running. Test the siren by activating a zone on the dashboard and then triggering the alarm. The alarm should sound either until the SirenTimeout is reached (default 30 seconds) or you deactivating the zone from the dashboard. You can set the SirenTimeout setting in the alarm.py file.

I hope you have enjoyed this project. For support join the support forum on the home page and post questions there.