About a year ago I received a phone call from a friend with bad news. He had been out running some errands with his newly married wife (only back from their honeymoon for a week) when an intruder broke into their home. The bandit got away with a carload of expensive electronics, but also something irreplaceable: all of their honeymoon pictures which were on their laptop and digital cameras. Knowing that I am somewhat of an electronics-guru, he was calling me to ask, “Is there any way we could throw together a security system for my house without it costing a ton of money?” The gears in my head immediately began spinning as I responded, “Oh, definitely!”
Please note that this was a personal/fun project and was not done with the level of professionalism that you would expect in a business situation.
My friend’s home has an enclosed patio area on the back side which has a glass slider door. This is where the burglars had entered and is where he wanted the security system to monitor. We agreed that if the system could detect someone entering his home in that area, and trigger a very loud alarm, that that would frighten most intruders and cause them to flee the scene. The one catch is, if he or his wife enters that area, the alarm cannot immediately go off — that would just be annoying! We also wanted to keep the total cost of the system as inexpensive as possible. Anyone could go out and spend $700 dollars or more to get an off-the-shelf system professionally installed, but part of the fun of building something yourself is saving money! Plus, my friend already had to spend a lot of money replacing all of the stolen goods.
Once I had a general idea of what my friend wanted the security system to do I started doing some research to compile an estimated cost and a description of operation. The system would need the following components:
The first major component is a sensor to detect the bad guys. We wanted to detect a person entering the house who would likely break a window and enter in through the porch area. I found the BV500GB, which is an IR motion sensor with built in glass breakage detection for $50. The sensor is very simple to use. It can be powered with 9 to 12VDC and it contains two relays, one for motion sense, and one for glass-breakage, which can be used to produce inputs to your microcontroller.
The second major component is the horn. We wanted something really loud and obnoxious that would scare off intruders but also cause the neighbors to look out their windows to see what is going on. I found this 115dB siren that can be powered with 6-12 VDC. That should do the trick.
A few other components that were needed include a 16-key keypad, to disarm the alarm once triggered, a toggle switch to disable the system, a buzzer to communicate status to the user, a power-supply (note that this one can screw into the wall) and a microcontroller to bring it all together. Of course I had a handfull of other circuit components but you can see those in the circuit diagram below. The total cost of all the entire system was right around $120.
The following flowchart describes the plan for the system functionality in detail. The firmware would consist of a main state-machine with 5 modes. Idle mode is where the process begins and in this mode the system should silently wait for the toggle switch to be turned on. Once switched on, the device progresses to Arming Mode. In Arming mode the buzzer should sound once per second while it monitors the inputs from the motion/glass breakage sensor. If no intruder is detected for three consecutive seconds, the device should progress to Armed mode. The device should remain in Armed mode until an intruder is sensed in which case it progresses to Warning mode. In Warning mode the buzzer sounds rapidly thirty seconds and check the keypad for the password to be entered. If the password is entered successfully the system returns to Idle mode. If the password is not entered within 30 seconds, the system should go into Crisis mode. Once in Crisis mode the loud, obnoxious horn should turn on and remain on for a maximum of 4 minutes. If the user enters the password or 4 minutes go by, the device will return back to Idle mode.
To keep this project inexpensive I choose to not have a printed circuit board professionally made. Many electronics stores sell prototype circuit boards that you can solder components to to build circuits. I used one of these and for that reason I did not draw up the circuit with and software tool. I went old-school and used pencil and paper! See the schematic below.
I started the circuit design with the power supply because you can’t do much without power. The transformer that I picked out is specially designed for security systems. It has a built-in flange and a screw that can be used to securely attach the transformer to a wall output. This prevents a burglar from simply unplugging the device if the see the power source. The transformer converts the 120VAC signal in the wall to an AC voltage around 15 Volts. The circuit needs a DC voltage between 9-12 Volts to power the sensors, horn and buzzer. Also a 3.3VDC supply is necessary to power the microcontroller. I used two adjustable voltage regulators (LM317’s) to produce these voltages.
The 16-key keypad has 4 pins that connect to columns of buttons and 4 other pins that connect to rows of buttons. When a button is pressed the keypad forms a connection between a row and a column. I connected the 4 column-pins to outputs of my microcontroller. I then connected the 4 row-pins to inputs of my microcontroller. In order to determine if a key is pressed, I simply turn on one of the column outputs and look at the 4 row inputs. If any of the row inputs are ON, I know that the key is pressed that corresponds to that row and the powered column.
The microcontroller IO pins can only produce 3.3 Volts and can only source a very small amount of current (about 20mA). In order to turn the buzzer and the horn on an addition component is necessary that can handle a higher voltage and current. I choose to use MOSFETs because they are small and cheap (less than a buck a piece) and they can easily switch the 10Volts on and off.
While the system has not had the chance to prove itself in a real break-in situation, I still consider it a great success. The circuit was really fun to build and it functions exactly as planned. To arm it all you have to do is flip the switch to ON and walk out of the room. Once the motion sensor detects no motion in the room, for three consecutive seconds, the system produces three fast beeps to indicate it is “armed and ready”! If you walk into the room the warning buzzer starts beeping quickly to alert you that the loud horn is about to go off. After 30 seconds, if you do not enter the password into the keypad, the horn does go off and it is certainly loud. We were easily able to hear it out on the street in front of the house! Entering the password into the keypad stops the alarm and the device begins trying to re-arm. From a user perspective, it is very easy to understand how it functions and what mode it is in at any given time. The “customer” is not an engineer and he was able to fully operate it in less than 5 minutes.
- Store the password in NVM and allow the user to change it at runtime (currently it is hardcoded in)
- Add Ethernet support and send a text message or email when the alarm is triggered
- Add a camera that could snap some photos when alarm is triggered
I really like this. I want to build my own. This could get the arduino treatment soon. Have you thought about open sourcing the software?
An Arduino version would be cool. For future improvements I would love to add a WiFi/Ethernet controller and have the system send out an email every time it is triggered. I will throw the code up on github when I get a chance. I’ll respond to your comment again once it’s up.
Very cool project! My nerdy side enjoyed reading it.
Jordan: It could also send a notification to cellphone.
Comments are closed.