Monday, February 10, 2014

Raspberry Pi Home Security + Automation - Phase 3

In Phase 1 and 2 of my previous posts in this series, I showed the basic setup of a Home security  +  automation system. No home security system is complete without a siren/alarm so this posts addresses that.

I was looking for a way to trigger the alarm and wanted it to be completely isolated from the Pi GPIO to avoid false triggers.  I also wanted to avoid using more GPIO for this project so I decided to a 433Mhz wireless siren similar to the one on Ebay here

If you open up the wireless strobe siren you will find this:


There is a small switch on the PCB to switch the circuit on/off. A white wire goes from the board to the piezo siren. For initial testing, I would recommend disconnecting the siren so that you can verify that your system works correctly without the really loud (90 dB) siren.

A 433MHz transmitter accompanies the strobe/siren to trigger it. I wanted to decode the code sent by this to allow me to trigger the siren myself. So I hooked it up to a 12V battery below and pressed the test button (see picture below).


The receiver already connected to the Pi (as shown in Phase 1) will help you find the code for your siren module. (use RFSniffer provided on the ninjablocks website to do this)

Here is a  short video showing the system in action.

Note - 
  • The 433 MHz door/window sensor  shown here is actually one that is normally connected to my  door/window and is not the one provided for triggering the siren. 
  • I have removed the waits in the code to trigger the siren immediately for the purpose of this video. You would normally have a delay to allow system disarm by an authorized individual



17 comments:

  1. Hi Trushant,

    I also started to make my home smart.
    By studying I accidentally visit your page.

    I have a business proposal based on this.

    Please mail me at civanescu at gmail dot com.
    Best regards,
    Claudiu

    ReplyDelete
  2. This comment has been removed by a blog administrator.

    ReplyDelete
  3. Wow! This is a very useful page and I really enjoyed reading article and all users’ comments. Smart Home Group is a privately owned and operated Technology Distribution company offering a full range of Home Automation solutions. With a strong brand presence in the Australian market, Smart Home Group continues to provide value for money solutions across a growing range of products. Thank you for sharing valuable information.

    ReplyDelete
  4. thank the Smart Home Group is one of the best choices

    ReplyDelete
  5. Hi!
    I assume you are using 'sudo ./codesend 12345' to send the code to the siren? How do you implement this command in the scripts when alarm is activated? I seem to have one big problem here: when I connect data-pin of transmitter to GPIO17, the alarm is deactivated. I will only get the message 'received 15' for example when I open a door contact but alarm is not triggered. If I disconnect data-pin from GPIO17 the alarm work as expected.
    I would be grateful if you could try to understand what the problem might be.

    ReplyDelete
    Replies
    1. Please read this post - http://tkmaker.blogspot.com/2014/01/raspberry-pi-controlling-433-mhz-remote.html

      You have to implement the code in the alarm.py script once the alarm is triggered.

      if (trigger_status == "1"):
      #Allow some time (45 sec) to disarm the system
      time.sleep(45)
      print "Trigger recvd. Sound the alarm!!!"
      os.system("sudo ./send your_code")

      With Tx data pin connected to GPIO 17 and Rx data pin connected to GPIO 21 you should not see any issues. Verify all connections and try again. When you say alarm is de-activated what do you see happening exactly? Try debugging it one step at a time

      Delete
    2. Thanks for your reply Trushant! By alarm 'de-activated' I mean that the alarm is not responding to opening of the door contacts. I can only see the loop 'armed status =1' on the screen in putty. But if I remove Tx data from GPIO17, I will read 'received 12345' then 'Trigger recvd. Sound the alarm!!!'. Both commands: 'sudo ./RFSniffer' and 'sudo ./send 12345' are working when run manually with both Tx and Rx connected at the same time. The siren is sounding when I run the code manually. The alarm is triggered when opening the door contacts if the Tx data pin is not connected to GPIO17. I will then get email and see in Putty: 'sending code 12356', but because Tx data pin is not connected the siren will not sound. I have to add that I am using 'GPIO Breakout Pro' but I hope that it is not causing any problems. I re-checked the soldering on the breakout board but could not find any problems. I believe the problem has to be software related. What do you think?

      Delete
  6. I tried debugging the alarm.py script with Python pdb. I get no errors if the script is run as root: 'sudo python alarm.py'. But if I quit the debugger with pressing 'ctrl+c' I get this error message:
    'Traceback (most recent call last):
    File "alarm.py", line 81, in
    kill_child_process()
    File "alarm.py", line 33, in kill_child_process
    print "Killing RFSniffer process pid %s"%p0.pid
    NameError: global name 'p0' is not defined'
    As I am new to Python I don't know if this is of any significance to the problem I am encountering. Also I can see the 'control.py' is calling 'alarm.py' as root so that should not be related to the script not getting access to GPIO pins. I am running all scripts as user 'pi' but with executive rights.
    Any new ideas are appreciated

    ReplyDelete
    Replies
    1. Hi Jens- I know what the problem is now. The RF Tx uses GPIO 7 and my original code also used the same GPIO for the keypad. I changed the code on my side but didnt update the post or the code in git. (I will fix this). For now change the line in keypad.py that controls the GPio being used to this:
      COLUMN = [4,22,10]
      This would use GPIO pins 4,22,10 instead of 4,17,22. No one else commented about this so I assume no one else is using the whole system as I am using it today.

      Delete
  7. Thanks that's great Trushant! Yes that fixed the problem instantly! I assume you mean the RF Tx uses GPIO 17 and not '7'. I did strike me that the keypad was connected to the same GPIO 17 as the RF Tx data, but eventually I forgot to mention it or think that it had any significance.

    ReplyDelete
  8. The security system you build is very clever and very functional is a simple installation, but want to add siren, radar traps. www.synagermos.eu

    ReplyDelete
  9. Very interesting, your brain is very intelligent. This security system is very useful for home. Now many companies are providing this type of security system for home, smart phones, laptops, shop and many more. These security systems help to protect from thieves.

    ReplyDelete
  10. Because of this many swing gates must have a control panel as a part of the system. Smarter cctv system

    ReplyDelete
  11. Thank you to all of the members for supporting the event and of course a very big thank you to all of our sponsors, the ISIA Awards would not be possible without you. Smarter Security Melbourne

    ReplyDelete
  12. I like your post. It is good to see you verbalize from the heart and clarity on this important subject can be easily observed... Security cameras

    ReplyDelete
  13. I just couldn't leave your website before telling you that I truly enjoyed the top quality info you present to your visitors? Will be back again frequently to check up on new posts.
    home security camera installation service

    ReplyDelete
  14. Hello Wow what an article I truly delighted in perusing this I will return again to peruse, And you are searching for best smart home installation near me Please visit us security guard services

    ReplyDelete