?

Log in

No account? Create an account
Android Garage Door Opener, part 2 - brad's life [entries|archive|friends|userinfo]
Brad Fitzpatrick

[ website | bradfitz.com ]
[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

Android Garage Door Opener, part 2 [Oct. 26th, 2008|12:06 pm]
Brad Fitzpatrick
[Tags|, , , ]

This is a follow-up to my previous post to say:

SO. FUCKING. AWESOME.

I got it all working. I now have an Android Activity (GarageDoorActivity) which interacts with an Android Service I wrote (InRangeService), letting me start and stop the service's wifi scanning task. The service gets the system WifiManager, holds a WifiLock to keep the radio active, and then does a Wifi scan every couple seconds, looking for my house.

When my house is in range, it does the magic HTTP request to my garage door opener's webserver (HMAC-signed timestamped URL, for non-replayability/forgeability if sniffed) and my garage door opens. Complete with a bunch of fun Toast notifications (like Growl) and Android Notifications (both persistent ongoing notifications for background scanning, and one-time notifications for things like the garage door actually opening).

I just threw on some shoes and hopped on my motorcycle to do a test lap around the neighborhood. When I got to the corner, I pulled up the activity and press "Start" (aka "Going home now"). A lady on the corner saw me playing with my phone on my motorcycle and said, "The reception's not so good up here." I thanked her, not wanting to explain what I was actually doing.

I then finished the lap around the block and the garage door started opening a few houses away. By the time I pulled up, I could already back the bike into the garage. HELL YES.

Update 2008-11-16: The source code is now available.
LinkReply

Comments:
[User Picture]From: matthew
2008-10-26 10:17 pm (UTC)
Personally I just put a garage door opener in the sleeve pocket of my riding suit. Of course, that won't stop me from using your system :D

So most importantly, how is your garage door opener wired into a web server?

Edited at 2008-10-26 10:18 pm (UTC)
(Reply) (Thread)
[User Picture]From: brad
2008-10-26 10:37 pm (UTC)
Custom webserver (little Perl script hanging off xinetd), heyu, and an X10 relay.
(Reply) (Parent) (Thread)
[User Picture]From: brad
2008-10-26 10:38 pm (UTC)
And yes, arguably the x10 is the weakest link here. But I might argue a rock through a window is weaker.

I was considering putting two x10 modules in series to greatly expand the search space.
(Reply) (Parent) (Thread)
[User Picture]From: matthew
2008-10-26 10:44 pm (UTC)
Can you get a wire to the garage door opener unit? It might be fun to hack up a small interface that could activate the unit and also sense the door position and maybe even the state of the electric eye.
(Reply) (Parent) (Thread)
[User Picture]From: brad
2008-10-26 10:49 pm (UTC)
I'm already running bellwire over to the garage door unit in parallel with the existing button's wiring. I was just too lazy to build my own peripheral, so I used X10. If I had a USB relay, that'd be ideal from a security standpoint.

Reading the state of the garage is also important, but I was just thinking a webcam. More fun (since I already have speakers in the garage hooked up to my garage computer) is to detect the state of the garage by playing loud tones and measuring the echo. Sound presumably would bounce around and echo differently with the garage open vs. closed.
(Reply) (Parent) (Thread)
[User Picture]From: matthew
2008-10-26 11:00 pm (UTC)
You could do something quick and dirty with an arduino board, a relay and maybe a relay switch for detecting door position.
(Reply) (Parent) (Thread)
[User Picture]From: brad
2008-10-26 11:22 pm (UTC)
Hardware isn't really my thing.
(Reply) (Parent) (Thread)
[User Picture]From: brad
2008-10-26 11:22 pm (UTC)
(as in I suck at it... I wish it were my thing.)
(Reply) (Parent) (Thread)
[User Picture]From: matthew
2008-10-26 11:54 pm (UTC)
Well let's fix that. Go get yourself an arduino board. You can get the basic board or a nice little kit with a bunch of useful bits.

Then all you need is a relay to drop into the prototyping area and the rest is software. I think that I've got a relay that'll do the job sitting on my desk at work. Once you work out the software we just need to solder together the relevant bits (I can do that part) and you have yourself a USB garage door opener.
(Reply) (Parent) (Thread)
[User Picture]From: mart
2008-10-27 12:01 am (UTC)

I'd second this. A friend of mine bought one of these kits and had it doing all sorts of cool stuff within a few days of it arriving.

(Reply) (Parent) (Thread)