I wanted to make an inexpensive home security and automation system with the following goals:
- Home security system controlled by the internet or a 4x3 keypad
- Use 433MHz Door/window sensors to trigger an alarm
- Use 433MHz wireless switches to control home lighting
- Actions on alarm trigger - Siren and send out an email/tweet
- Future enhancements - Laser trip wires!
Update 1: I added 2 webcams to the system and any motion now triggers an alarm as well.
Update 2: Check out phase 2 of the project here, which adds internet controlled outlet switches.
Update 3: Check out phase 3 of the project here, which adds a wireless siren + a demo video of the system.
Update 4: I swapped the 433Mhz receiver for a much better one based on reader Kris's feedback. Updated original post below.
Update 5: The information from all the phases of this project have been consolidated and written up as an instructable here: http://www.instructables.com/id/DIY-Home-Security-Automation-using-a-Raspberry-Pi/
System Overview:Update 3: Check out phase 3 of the project here, which adds a wireless siren + a demo video of the system.
Update 4: I swapped the 433Mhz receiver for a much better one based on reader Kris's feedback. Updated original post below.
Update 5: The information from all the phases of this project have been consolidated and written up as an instructable here: http://www.instructables.com/id/DIY-Home-Security-Automation-using-a-Raspberry-Pi/
For Phase 1 - I plan on enabling the home security functionality. Phase 2 will be the home automation (wireless light control etc.) and additional security features like webcam motion detection and potentially laser trip wires.
Hardware:
I picked up an inexpensive set of 433MHz transmitter-
433MHz Tx-Rx pair (set of 2)
I am now using a 433MHz receiver ($5.99) suggested by Kris (Thanks!) which is much better than the one originally recommended. Link for that item is here:
Updated module - 433MHz super heterodyne receiver
433MHz Door/Window Sensors (set of 4)
For the input interface I picked up a 4x3 membrane keypad available on the Adafruit website ($3.95)
I have 2 webcams that I use for this project:
- An inexpensive USB webcam connected to the Pi directly
- A Tenvis JPT3815W IP Webcam connected to my home internet.
Software:
433 MHz RF communication on Pi:
I found this article on using 433MHz Tx-Rx modules with the raspberry pi. Follow the instructions here to install the 433Utils package.
http://ninjablocks.com/blogs/how-to/7506204-adding-433-to-your-raspberry-pi
A couple of points to note here:
- The outputs of the receiver are 5V TTL and I wasn't so pleased connecting them directly to 3.3 V tolerant Pi inputs.So I used a simple voltage divider circuit (220 ohm/440 ohm) to drop the voltage to something around 3.3 V.
- The receiver from Ebay does not come with an antenna. This threw me off initially because I wasn't receiving any code unless my transmitter was few inches away from the receiver. The recommended length for an antenna for this module is a 172mm long one (1/4 wavelength).
- I modified RFSniffer.cpp to write to a file, if the code matched my specific transmitters.
if (value == 0) { printf("Unknown encoding"); } else { printf("Received %i\n", mySwitch.getReceivedValue() ); if (mySwitch.getReceivedValue() == enter your transmitter code here ) { system("sudo echo -n 1 > trigger.txt"); } }
Run a "make" in the RPi_utils directory to create an updated executable.
You will need to install WebIOPi for the web interface.
You will also need motion to detect movement using any webcam. Check out my previous post here to see how to set this up.
Python code for rest of the software can be found on github:
https://github.com/tkmaker/RaspberryPiHomeAlarm
A shout out to Chris Crumpacker for enabling the 4x3 keypad code on the Pi. Thanks!
You can modify the passcode to arm/disarm the system from the keypad via keypad.py
You need to modify intruder_mail.sh with your email settings. You can also customize your email subject/message in this script.
Code overview:
There are 2 main scripts of importance -
- control.py - Calls keypad.py and alarm.py. Arms/Disarms the system based on web/keypad interface.
- alarm.py - Monitors the system status and if armed, checks for triggers before sounding an alarm.
Setup:
I have the RF receiver hooked up to my Pi (rev B) with data input on GPIO 21.
The 4x3 membrane keypad is connected as follows:
- Pin 7 on the keypad is ROW 0- GPIO 18
- Pin 6 on the keypad is ROW 1- GPIO 23
- Pin 5 on the keypad is ROW 2- GPIO 24
- Pin 4 on the keypad is ROW 3- GPIO 25
- Pin 3 on the keypad is COL 0 - GPIO 4
- Pin 2 on the keypad is COL 1 - GPIO
1722 - Pin 1 on the keypad is COL 2 - GPIO
2210
Green LED is on GPIO 7
The 2 webcams are monitored as 2 different threads via the motion software. You can check out this post here to see how to set that up.
I have modified /etc/motion/motion.conf to write to trigger.txt on motion detection.
# Command to be
executed when a motion frame is detected (default: none)
on_motion_detected
sudo echo -n 1 > /home/pi/trush_workdir/scripts/homealarm/trigger.txtI also have it set up to upload images and videos to my Google drive (see my previous post for details)
Start control.py as a webiopi process:
sudo python control.py -m webiopi -d 8085
You can use any port of choice above. I used 8085.
You should see an interface like this once you go to your Pi IP address:8085
If you pull the website up on a touchscreen phone connected to your home internet, you can press the arm/disarm buttons to activate/de-active the system. The rest of the buttons are not enabled yet.
You can also enter the passcode (default 123) on your keypad to arm/disarm your system.
To test out the system -
- Arm it via the web interface or keypad - The terminal should show the status here
- Trigger a fake intrusion via the door sensor - Look for the alarm triggered message. The LED will blink 20 times and an email will be sent out
- Disarm and arm again
- Trigger a fake intrusion by moving in front of the webcam - Look for the alarm triggered message. The LED will blink 20 times and an email will be sent out
For now, the alarm action doesn't include a siren - I plan to add this as part of phase 2 as well.
Please feel free to leave your questions and comments Any suggestions to improve or enhance the system are welcome.
So many thanks for this useful post. I found the Membrane Keypad.It seems like an order of magnitude less expensive than conventional EM keypad, and was wondering how to use it, when I found your post.
ReplyDeleteGlad you found it useful elec flex. I also like the membrane keypad for its flexibility. It can be installed in a system easily.
ReplyDeleteIt's an awesome conceptualize well-explained post on the Membrane Keypad. Thanks again for your kind response and I expect the more similar informative article from you.
DeleteThat's awesome. Devices like these can provide safety to the user and people can barely compromise any of their privacy using new technological devices. I think with time, the safety of the consumer will never be breached by any means.
ReplyDeleteRegards,
Arnold Brame
Health And Safety Consultant Norfolk
Thanks Arnold. With technology surrounding us in this age, it is probably put to its best use improving the quality of our lives.
DeleteNice work man, glad I could help out a bit. Would love to see pictures of it all wired up
ReplyDeleteThanks Chris. Yes, that was on my list of things to do. I just uploaded one picture. I am working on cleaning a few things up and adding control for lighting soon.
DeleteImprnt are engaged in offering a quality range of Biometric Attendance Systems . Due to their efficient performance, minimum maintenance and high identification speed, the systems are highly appreciated by our clients.
ReplyDeleteHi! This is a great project / tutorial but I'm struggling with 433 MHz. How can you get the transmitter code (or any 433 MHz transmitter device code) to write it in the RFSniffer.cpp? I've got the same 433 MHz RXTX and door sensors. Thank You!
ReplyDeleteThanks Ani. The blog also sites this source for 433MHz code - http://ninjablocks.com/blogs/how-to/7506204-adding-433-to-your-raspberry-pi . If you go to this link and follow the instructions to get the 433Utils code from github, you can access the transmitter & receiver code. RFSniffer.cpp is part of that package. That link also talks about how to use the 433 MHz transmitter and receiver with a Raspberry Pi
DeleteSorry! English isn't my native. I have been talking about:
Delete...
if (mySwitch.getReceivedValue() == >!>!>!>!>!>!>!>!>!>enter your transmitter code here<!<!<!<!<!<!<!<!<!< ) {
...
but I figured it out the line above that print out what i need if i run rfsniffer and disconnect the 433 mhz door sensor to send data (i guess so).
That is right - You need to enter the code that you get from your door sensor when you run RFSniffer.cpp standalone (without the rest of the project code). This is similar to the example stated in the Ninjablock link. Good luck!
Deleteyour article is very interesting for the alarm system construction is very thought out and worthwhile. www.synagermos.eu
ReplyDeleteI've always wondered how those keypads work. I really love how you were able to demonstrate what goes on behind the scenes. Every time that I use mine I am going to think of this article now. It really inspired me to research more of this stuff. http://www.alarmresearch.com/commercial-solutions/
ReplyDeleteThis comment has been removed by a blog administrator.
ReplyDeleteThis comment has been removed by a blog administrator.
ReplyDeleteYour security system is very complicated and small size i really like it . Thanks for your information and also its very useful for me.
ReplyDeletevoip line Toronto
The given information is really nice...thanks for sharing....
ReplyDeleteThanks for this information! I started a little project that uses a part of this information. But I have one problem: I use the same receiver as you do (well, it looks exactly the same), but even with an antenna (17 cm copper wire), I cannot get it to receive signals from the door sensors in another room. Reception is just really bad. Do you have a solution for this?
ReplyDeleteThank you,
Kris
Yes the range for the receiver from eBay is pretty poor. I have it working across 1 room with this setup. I am experimenting with other transcievers like cc1101 to get better range. The transmitters work fine across my home with 2 levels
DeleteThanks for your reply. The transmitters indeed work fine for me as well, nice range. Will you keep us up to date with your findings with other receivers? Thank you!
DeleteThis comment has been removed by the author.
DeleteGood news: I picked up the receiver below from eBay and now the range is good: I can receive signals from the end of my garden and from other floors in the house. It's a few euro's more, but at least now it works as it should.
Deletehttp://www.benl.ebay.be/itm/280936648330?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1497.l2649
That is great! I am going to try that out as well and will update this blog with the results. Thanks for the update! What Antenna did you use with this?
DeleteI had the original 433Mhz receiver and RFSniffer was picking up my codes at VERY small distances. I replaced the original receiver with the one you suggested and do not pick up any codes. Is there anything to do except swap receivers because I am confused why this didn't work with the new receiver when things were working with the old receiver? (do both 5v and ground pins need connected on the new receiver?)
DeleteThanks for sharing this info.
I noticed that the RFSniffer is using a lot of CPU. How are you guys dealing with that?
ReplyDeleteI have noticed this as well. Has anyone find a good resolution to this?
DeleteThanks for the information.
ReplyDeleteI will bookmark it.
Lloyd Security
Hi!
ReplyDeleteVery good project, thanks!
However I can't seem to get the door sensors to trigger the alarm. I have changed the RFSniffer.cpp with the code above and inserted my correct code from the door sensor. I do not get any "received code" from the door transmitter when the alarm is armed, if I open it. I do get the code from door transmitter if I run sudo ./RFSniffer.cpp
The alarm is however trigged by motion in front of the webcam.
Any suggestions?
I second the above regarding very short receiving distance of the receiver. Any news regarding the cc1100 tranceiver?
I am trying to understand your issue better - So for the same distance between the sensor and the Pi, you were able to get a code from the door sensor when you run it with sudo but not when the alarm is armed ? That would rule out receiving distance and would point to a software issue. You could add more debug/print statements in the python code to make sure it is going through all the desired code and running RFSniffer correctly.
DeleteRegarding short receiving distance, I am going to try out the receiver suggested by Kris and will update the blog if it works out better.
This comment has been removed by the author.
DeleteHi thanks!
DeleteI got it working!
I think the Alarm.py script was not able to activate RFSniffer because of uncomplete compilation of the 433Utils software, which may have happened when I connected the receiver before complete software install. At first I was using the exact same setup as you did.
The receiving distance of the receiver was at 1m. I adjusted the frequency and got it working across one room.
However I did order a different receiver - It look like the same receiver as Kris - the Superheterodyne 3400 receiver, from China. When connected at 3.3V it worked across two floors without problems. I did use a 17,3 mm coaxial copper wire as antenna. I also changed to other door transmitters without external antenna and it also connected with the new receiver.
How do you setup the RFSniffer.cpp file if you want to connect more than one door/window sensor?
DeleteAfter some more testing I believe I am getting false alarms from neighbours sensors. My own sensors does trigger the alarm, but a door sensor not yet mounted or setup in RFSniffer.cpp was triggering my alarm. How is that possible?
In RFSniffer.cpp I wrote like this:
printf("Received %i\n", mySwitch.getReceivedValue() );
if (mySwitch.getReceivedValue() == 99300 or 336001 or 887700 ) {
It should work the way you have it unless someone else around you or some device in your home is transmitting the same code. Try to isolate which exact code is causing the false triggers.
DeleteThanks for your reply! The strange thing is it seems that a door sensor with the code: 5575735 is triggering the alarm -this is on of my door sensors not yet mounted. It is even not mentioned in the RFSniffer.cpp file yet, but it triggers the alarm anyway. I also had other code not mentioned in the RFSniffer.cpp file trigger the alarm which I simply don't understand
DeleteI think the problem might be related to writing these, or statements in RFSniffer.cpp. It seems when I tested if I write more than one code separated by, or, it open up the alarm to any 433 mhz code to trigger it. Is there any other way that works better?
DeleteProblem is solved as far as I can see. I changed RFSniffer.cpp with a series of, else if, statements, one for each door transmitter. This fixed the problem with random codes triggering the alarm.
DeleteIt would have worked if you had used '||' instead of 'or' as well
DeleteI also tried it like this but got the same problem as when using 'or'
Deleteif (mySwitch.getReceivedValue() == 99300 || 336001 || 887700 ) {
I don't know why it doesn't work. Did you use this method?
You can even control your program using GTALK if you would like to.. That is much simpler way, if going thru web page is tedious.
ReplyDeleteFollow this link to create a Gtalk Bot and run in parallel to your main thread. You can pass messages between them using Queues. It can be 2 way communication - You can send commands to pi OR pi can alert you when there is an alarm.. :)
http://mitchtech.net/raspberry-pi-google-talk-robot/
Issues surrounding Wireless Security can never be over analysed. There are many factors which influenced the development of Wireless Security. Cited by many as the single most important influence on post modern micro eco compartmentalism, there are just not enough blues songs written about Wireless Security.
ReplyDeleteWireless συστηματα συναγερμου are very good and with high technology and we provide very high security
ReplyDeleteI've been thinking about getting a home security system to make sure that when I go on trips, nothing happens to my home. I remember that growing up, we had break-ins in our neighborhood frequently. I think that the best course of action is probably to get a security system that will really help me to know if someone is trying to break into my house. http://www.videotecsecurity.com/
ReplyDeleteSecurity products are very important for safety of our house and family. Contact us for purchase & installation of various Home Security Devices.
ReplyDeleteI'm impressed that you actually put together your own security system. I don't know enough about wiring and all that to make my own system. How long did it take to put this together? http://www.alarmresearch.com/residential-solutions/
ReplyDeleteGood idea, I always like this type of posting. Your home security system is very helpful to protect home. Anyone can use your security system easily. I think many people will use this home security system.
ReplyDeleteIt is fascinating that as technology advances, we have ways to explain it and understand it better. Trying to understand a home security system would have probably been easier a decade ago, but now we are much more familiar with the terms these days. Even though the systems are getting complex we understand the words they use to explain it better.
ReplyDeletehttp://www.marshallalarm.com/securitysystems.asp
Thanks for sharing such a nice knowledge with us. A must read blog. home security companies
ReplyDeleteSplendid information you have given here in the blog, you have actually impressed me yes!! best home security
ReplyDeleteThinking about trying this project. Is there away to determine which door sensor is triggered? Do they send different codes?
ReplyDeleteYes each transmitter sends out a different code that will show up on the pi on RF Sniffer
DeleteThe procedure of doors installation is very important so, i want to fine exact type of blog. Thanks for commenting. Security Doors London
ReplyDeleteReally nice information about security protection. Thanks a lot.
ReplyDeleteemergency alert system georgia
Your blog is very interesting and informative.Security systems are becoming more and more available, and the technology behind them is evolving every single day.
ReplyDeleteWireless intruder alarm
I have made it my business to watch out for subtle security alarm industry changes over the years. Each and every year I can see these changes slowly take shape and take hold on the Alarm Companies that provide systems for consumers like you and me.
ReplyDeleteThe majority of these changes in the past went unnoticed by the average Alarm System protected household and business. They were slight adjustments made by the Alarm Dealers, Manufactures and Service Providers and unless you were looking, you missed most of them
Hi buddies, it is great written piece entirely defined, continue the good work constantly.pop over to this website
ReplyDeleteGood share about security alarm,.
ReplyDeleteSurveillance Cameras
impressive information shared.
ReplyDeleteself defence flashlight
Thanks for always being the source that explains things instead of just putting an unjustified answer out there. I loved this post.
ReplyDeletewifi sport camera
It's really a nice and helpful piece of information. I'm glad that you shared this helpful info with us. Please keep us informed like this.
ReplyDeletehome security cameras Installation los angeles
This is easier and surely gives comfort to internet users. Thanks for sharing. Post like this offers great benefit. Thank you!
ReplyDeletewifi inspection camera
More homeowners and business owners than ever are planning on installing security systems ranging in sophistication. Kathy Lott, Complete Home Alarms
ReplyDeleteI was very pleased to find this site.I wanted to thank you for this great read!! I definitely enjoying every little bit of it and I have you bookmarked to check out new stuff you post.
ReplyDeletegutter vacuum cleaning
He correctly acted to bypass the missing door contact so he could continue to arm the remaining alarm sensors. Security quote
ReplyDeleteYou have got some great posts in your blog. Keep up with the good work.
ReplyDeletesecurity cameras company
Hello, U write some extraordinarily attractive blogs. I always check back here frequently to see if you have updated
ReplyDeletewifi inspection camera
Great blog, keeping me from working. All the Best
ReplyDeletewifi inspection camera
It contains useful and beneficial content. To me, you are doing the excellent. Your way with terms is elegant and relatively attractive. so keep it up.
ReplyDeleteIMT ref cam
Cool blog you got here and thank you for the valuable information.
ReplyDeleteDoor locks
Thank you so much, this a great help. brief description for submission thanks.
ReplyDeleteκατασκευη e-shop
Super blog and very nice information which i really appreciate it,
ReplyDeleteroofers
I appreciate your blog and very nice presenting your all information about the quality fence in Australia it's really very good.
ReplyDeletefence company Australia
Your blog's all information are really very nice and interesting about the Best survival gear websites i like it.
ReplyDeleteEmergency shelter
yes definitely this type of blogs are really help for people great job.
ReplyDeleteroof leak repair
Wow!nice article and containing allot of information about the Sugar Land Roofing well done.
ReplyDeleteSugar Land Roofing
Such a nice blog and i appreciate your all efforts about the Home Improvement it's really good work. well done.
ReplyDeleteAnti fog film for kids bathroom
Interesting blog and very amazing detail about the Urban Construction Pack well done keep it up.
ReplyDeleteUrban Construction Pack
You have some honest ideas about the st louis Commercial Quote share here I really get many information and discovered most peoples will agree with your blog.
ReplyDeletest louis Commercial Quote
These conventional unmonitored systems have various kinds of sensing units placed around your house: for instance, SecurityInstallers.com.au
ReplyDeleteVery interesting and informative blog and about the Bauführung and I must appreciate your work well done keep it up.
ReplyDeleteBauführung
Hello! I just wish to give an enormous thumbs up for the nice info you've got right here on this post. I will probably be coming back to your weblog for more soon! surveillance cameras alice
ReplyDeleteI read that Post and got it fine and informative. surveillance miami
ReplyDeleteI surely acquiring more difficulties from each surprisingly more little bit of it cheap guest house in springs
ReplyDeleteMy friend mentioned to me your blog, so I thought I’d read it for myself. Very interesting insights, will be back for more! hotel prices in hawaii
ReplyDeleteVery informative site, i must bookmark it, keep posting interesting articles...
ReplyDeletecobblecrete leicester
This comment has been removed by the author.
ReplyDeleteDon’t know how to design your membrane switch panel? It Doesn't Matter, JRPanel would like to offer you free Membrane Switch Panel design service for you! Leave the Membrane Switch Panel to Us!
ReplyDelete