Wednesday, September 14, 2011

Android app to monitor & open and close garage door

Have you ever wanted to know if your garage door is open without having to go and check it? There have been many blog posts to light an LED when you leave your garage door open, but I want something more convenient. I decided to write an Android app that would allow me to monitor my garage door and even open or close from anywhere. I am going to provide complete instructions for building the required hardware and the android app code.

Monitor your garage door with an Android app
What is required? We need to build the following:
  • Using a Netduino board (or an Arduino board with an Ethernet shield) build a sensor to detect if the garage door is open or closed. I chose an infrared phototransistor so I would not have to make physical contact with the door and because it's cheap! Like $1.13 cheap!
    Build and program a garage door sensor
  • To open or close the garage door I wired an Optoisolator to a spare garage door opener.
    Build and program a garage door opener
    Open and close garage door with your Netduino
  • Write a program (or you might hear it referred to as a sketch) to check the sensor and determine if the door is open or close and report it back over HTTP
  • Even though it's not required, I wrote a second RESTful webservice to talk to the Netduino web server (see diagram). That way the Netduino webserver is never exposed outside my private network. I have another computer with the RESTful webservice that has a layer of authentication that is exposed to the internet.
  • And finally an Android app that will display if the garage door is open or closed as well as open or close it. Here are step by step instructions (with complete source code) for writing the Android App.
I will be covering each step with a detailed post.


Jack Lawson said...

Really looking forward to seeing this series of posts. I bet you could do some awesome things with Arduino and the Tasker app.

Greg Zimmers said...

I have toyed with the idea of using this with Tasker. The only thing stopping me is I have not bought it yet. It might be time to buy it.

Anonymous said...

Hi Greg-

Thank you for this. This is wayyyy beyond me as I am not a programmer but I love the concepts of hacking things together and home automation. I don't know if I will be able to do this but I would love to try.

I know this is basic stuff for you, but can you clarify for me what is hooked into what? Does a netduino receive commands without being physically attached to a computer (i.e., you don't need a computer in your garage, correct)? I assume that's what the "net" in the name is for. What about powering the netduino/sensor?

Also, would the android app be able to give you a text or alert sound when the door opens? Could it log the times? This would be great for knowing when a teenager gets home if you are away or sleeping.

Thanks so much!

Greg Zimmers said...

The Netduino is connected through an Ethernet cable. The Netduino talks to the computer over the network with HTTP requests and responses. There is no need for a computer in the garage. The Netduino has it's own 5 volt power adapter that plugs into a wall outlet. Yes you could send text messages and emails with this setup as well as log events. The Netduino plus has an SD card that can store up to 2GB.

Anonymous said...

I thought I posted a reply but I must have canceled somehow...

Sorry, can you clarify, what is the netduino connected to? If I have my router in the house and the netduino in the garage, do I need to run an ethernet cable out there? Sorry if this is really basic stuff.


Greg Zimmers said...

Yes, the Netduino is attached to your router by an ethernet cable. You could put the Netduino in the garage but you don't have to. Basically the connections are Router attached to Netduino by ethernet cable attached to infrared sensor by two tiny wires. That gives you a lot of flexibility where you locate each component. I put my Netduino in the basement near my router, then I ran two wires to the infrared sensor in the garage. I am working on shooting a video that I will post on YouTube. When it's done I will post a link here.

Anonymous said...

OK; that makes more sense to me. Unfortunately my garage is fairly far from the house so even if I got up the nerve to try this project I think that might be a dealbreaker. Maybe if a wifi netduino comes out...


Greg Zimmers said...

Actually you can do that! There is a wireless shield so the Netduino would not have to be physically attached. It's just costs more for the wireless adapter. The are called Xbee Shield if your interested.

Anonymous said...

OK; when you get your video up I'll evaluate if I think I'm up to this task.

Thanks for the work and the responses!

BenE said...

Hi Greg. Thanks for the awesome series of posts.

I had to change my netduino server code to listen on a different port (18001) because
my internet provider blocks port 80 from being served for security reasons. I
went into my router and fowarded the new port (18001) to the IP adddress and port
(18001) of the netduino.

If I use a browser from any computer, it works, I can query the garage door being
open or closed with http://:18001/checkdoor.

However, from a browser or from the garage door app on my phone (or andriod emulator) it
doesn't work. I can see (from debugging statements I added) in the emulator
that the bytes received by the server are zero.

I am thinking I need to write a second webserver like you did but I'm not really sure.
I think I'd like to anyhow for security reasons but I'm not sure how to start it.

Do you have some skeleton code for the RESTful webserver to help me out with that
part of it?


Vlad said...

Are you seeing a problem when netduino looses power (power outage) and then boots back up again the door will open? I have read that netduino will send 3.3V to the pin upon boot (this will activate garage door opener) and there is no way to prevent this, except adding additional transistors and resistors which makes things more complicated. How did you deal with this? What if you leave the house and there is a temporary power outage, this will open the door for everyone to come in.

Kyle Bale said...

You guys may no longer be interested in working on this or already done, but another solution to the wireless issue would be a WiFi AP client or wifi bridge. Like this:
I am an extreme newbie, but it seems to me that this method would be easier and potentially cheaper than a wifi shield.

Anonymous said...

Hi Greg,

Ur posts are awesome can you help me knowing how to automate the bike remotely.


Gopi Kishan said...

This is nice comment!!!!!
It describes the use of Android in the Samsung Galaxy mobiles..
Online Android Tutorial

Post a Comment