Garage Door Monitor

Garage Door Monitor Project

Prototype on my desk - black thing at the top is the reed switch that will mount to the door (green led is lit to show door is closed) - blue thing at the far right of the breadboard is a 3v relay - when it closes it will close the circuit on the garage door push button)

Prototype on my desk – black thing at the top is the reed switch that will mount to the door (green led is lit to show door is closed) – blue thing at the far right of the breadboard is a 3v relay – when it closes it will close the circuit on the garage door push button)

Background: While surfing around trying to educate myself on how to use the XBEE gadgets to enable the solar monitor project I happened upon some posts about people using them to monitor the status of their garage doors.  This struck me as a very practical application that could actually benefit us and leverage the work that I had already done.  On occasion we have gotten up (typically on the weekend in the summer) to find that we left our garage door open all night long.  Fortunately, this has never been an issue but it’s probably smarter if we don’t do it.  There was some minor crime in our neighborhood last winter when someone went around at night breaking into all the cars parked in driveways – nothing serious but probably better if we don’t tempt anyone by leaving our garage door wide open!

So, with that thought, a new project was born and it really only required a few additional parts.  Here’s what I used:

Parts List:

ITEMDESCRIPTIONCOSTPIC
Total cost = $64
Raspberry PiCredit-card sized linux server that runs Apache and MySQL and hosts the various php and python code files – I already had this but it sells for $35$0RPI
XBEE Radio – ReceiverThis connects to the Raspberry Pi sever so it can receive data from the remote unit (already had this in place from the solar monitor project)$0xbee
XBEE Radio – Transmitter(Same as the receiver) – I needed a new one for this project as I couldn’t leverage the one from the solar monitor project$29xbee
XBEE ShieldThis isn’t necessarily required but made life a lot easier (saves soldering and handles the power mgmt on the board)$19xbee_shield
Reed SwitchThis gets mounted on the garage door and let’s the system determine the open/closed state of the door$5REED_SWITCH
3v RelayThis lets me trip the existing garage door opener button next to the door in the garage by sending a command to the remote XBEE$43vrelay
BreadboardI initially got this just for easy proto-typing but this cool package of 6 little ones was a great find and 2 of them wound up in the final build!$7small_breadboards
5v USB Power Supply CordI seem to always have a handful of these lying around at any one time from old phones, toys, etc$0USB Power Cord
WireI just used some old telephone wire I had in the shop$0phone wire
Various jumper wires, leds, etcI had these from the kit I bought and used in the solar monitor project$0ELECTRONICS KIT
EnclosureI used a blueberry container from the grocery store that was sitting in the recycling bin!$0blueberry package

Code: Once I had all the parts it was a matter of cobbling the code together to make it all work.  I had the XBEE stuff all figured out already from the earlier work on the Solar Monitor so it wasn’t hard to tweak that.  Putting it all together consisted of the following pieces of code:

  1. Read the state of the reed switch to know whether the door is open or closed – essentially just monitoring one of the digital input pins on the XBEE to see if the switch is open (high) or closed (low) – also spits out some html so you can interface to this from a browser (only accessible on the local home wifi network):

     

    IPHONE DOOR PAGE

    Web page on Donna’s iPhone showing that the door is open…

    BB DOOR PAGE

    Web page on Jeff’s BlackBerry shows the door is closed…

  2. Send a command to “push” the button on the garage door opener to open or close the door – basically just change the XBEE digital io pin #0 to high for 1 second to close the circuit on the garage door opener push button via the 3v relay.  We do the same with the XBEE dio pin #4 which has a blue led connected to it just for a visual indication.
  3. A cron job running on the Raspberry Pi server at 8:30 pm launches a python program which checks the garage door status (ie check the status of XBEE dio pin #5 which is reading the state of the reed switch – if the pin is high the door is opened, low it is closed) and sends us a text message if the door is still open (with a link to close it if it is!)

    …this actually calls a php file to send the text message through Google Voice as I could not get this to work natively in python and gave up after much frustration:

     

    Text message sent from the cron job that checks the door status at 8:30pm each night

    Text Message telling us that we forgot to close the garage door!

With the blueberry plastic box closed up (the air holes in the box are nice for keeping things from getting too hot in the summer time)

With the blueberry plastic box closed up (the air holes in the box are nice for keeping things from getting too hot in the summer time)

The finished product!

Final installation – mounted to the inside garage wall. Black wire on the side is power – white wires at the top route to the reed switch and push-button opener

Installation: Mounting it in the garage was fairly easy using some old telephone wire that was lying around in my shop. Here’s the final installation (note the high-tech enclosure – aka a used plastic blueberry container that was about to go out in the recycling bin!) It’s up in a corner of the garage – conveniently close to a power outlet and short wire runs from the reed switch on the actual garage door and the push button opener right next to the inside entry door.

Key Challenges:

  • I initially bought a 5v relay to close the door opener switch – not sure what I was thinking but the XBEE maxes out at 3V so I spent some time scratching my head and eventually bought the right one.
  • The XBEE has a VREF pin that winds up being very important – it essentially tells the chip what the incoming voltage level is and it’s important in any calculations you do on the readings from the analog pins as well as measurements you might be making with a multimeter.  I didn’t fully understand this at first and neglected to supply it with the proper voltage.
  • When I first installed the reed switch on the garage door it got in the way of the cable as the door was moving up and down.  It didn’t cause any problems but would make a loud “snap” when the cable moved around the switch.  Donna nearly jumped out of her skin when she first hit the button after I installed it.  Fortunately it was a quick easy fix.
  • In normal fashion, after everything was prototyped and working like a champ, I then pulled my hair out for 2-3 days after cleaning it up and installing it in it’s final production spot.  The pin checking the status of the reed switch would not always read correctly.  I rebuilt everything a few times, cussed myself endlessly and only finally got smart and used good troubleshooting technique to break it down into lots of little parts.  One of the jumper wires I put into the breadboard had somehow gone flaky – arrrgh!

Next steps:

  1. So far it is running like a champ without issue for a few weeks.  I’m not sure how stable everything will stay but if there’s any flakiness I may need to automate a reboot/reset once a month or so.
  2. I might be too lazy for this but it could probably stand to move onto a pcb prototype board with some good soldered connections rather than the breadboard + jumper wires that it’s built with now.
  3. There are red/green LED’s that visually indicate whether the door is open or closed but they only update when the program to check the door status is run.  So, if the door is opened or closed normally from one of the remotes or from the wall switch then the LED’s are not correctly lit.  This is very minor and the best solution might be to just eliminate the LED’s as they’re really not needed but maybe I can come up with something more creative.
  4. I might change out the pics on the web page that show the door either opened or closed so they feature 5-year old Katie standing in front of the door (since we always smile when we see her pic!)

Acknowledgements: A couple of good web links helped me as I was tinkering with this:

http://www.robtennyson.us/post/zigbee-xbee-garage-door-opener

http://karlduino.wordpress.com/2012/09/23/arduinoxbee-garage-door-indicator/

http://www.adafruit.com/blog/2009/04/21/using-xbees-to-control-relays/

 

 

Leave a Reply