Back to the garage doors..

Time is a miserable thing, or maybe it is just the fact that my past efforts are tracked on this web site..
Just this week as I left for work and found my wife’s garage door open.   She had obviously driven off and had either forgotten to push the garage button or was out of range when she did push it.

This got me to thinking about my garage project which I thought I had just been working on last year.  This site shows me that it was almost 2 years ago..  ugh!  Where does the time go..

This was the original Garage Door thread…

Oh well, back to the project at hand..  I thought that it would be a great idea to have a little Android application that could ping my home server as I approached my house.  My wife and kids are also Android users so that idea really got me thinking about home automation and what could be done with a system like that.

There are products on the market that can control lights and other electric devices based on GPS, so this is nothing new.  (Quick shout out to Justin since he supplied me with a device to play around with a year or so ago; thanks!).  I think the thing about this is that it would be fun to build it myself, and it fit with the work I had done already related to my garage doors.

In this implementation I went with a relay to control the garage door.  I had originally planned to use GPIO and control the garage door opener directly, but using a relay is much easier and also quicker to remove if I decide to use the hardware somewhere else.

Side note:  I did find out today about WeMos devices that are based on ESP8266, offering a WIFI connectable device in a very tiny package.  Add a relay shield to the device and well, I have several on order from AliExpress…  🙂

Device size: 34 mm x 26 mm
Device size: 34 mm x 26 mm

For now I am happy with using a Uno to do the work with an Adafruit CC3000 WIFI shield.

For my own reference, here are some updated schematics of the door controller.
Door Controller Schematic - switches will be relays
Door Controller Schematic – switches will be relays


Simplified break down
Simplified break down

Step #1 – Arduino + Relay

First thing in my build was to create a small Arduino sketch that would trip a relay.  This was very straightforward.  Pictured below is the circuit which to start with simply triggered an LED.
The sketch was a basic digitalWrite to drive a pin high, in my case I used pin #2.
Next step was to merge the relay code with some of the Adafruit example code that can be downloaded from the CC3000 information page.  The end result was a very basic TCP/IP server which listened on port 1234 for connections.  Upon receiving a connection, the sketch would parse the “action” to determine what the client wanted.
I created only one action, but setup the sketch to handle any number of “action” tokens.  The control for the garage door has a light switch, plus I have 2 garage doors so plan on controlling both with the same Arduino (future WeMos 😉 device.
Working prototype
Working prototype
The Arduino code is attached.

Step #2 – Android Controller

The plan was to have an Android program that would track GPS locations of my wife or myself.  As we approach the house, the system would trigger the appropriate door to open.  Similarly as one of us left in the morning, the system would trigger the door so that it would close.
This of course brought up thoughts related to how I would know if the door had already been triggered through the use of the remote or wall mounted switch.  I figure that in the future, I will have a Ping sensor mounted on the ceiling that can see if the door is open.  The door slides up to the ceiling so it would be trivial to determine if the door were open.
If the Android application were to ping the web server because it was leaving the area, the system could also wait 30 seconds or so to allow the door to close by other means.
So I had some thoughts around all of this but ultimately I just needed something to trigger the door manually for my own testing.  The results of that effort are attached, and the video below demonstrates a successful test.
First rev of the Android software is attached.

Step #3 – Web Server and Brain of the Operation

The Android device would need to be able to report its location back to the system or there would be no way to know that it was leaving the area.  Granted that a disconnect from the WIFI network might be enough, but I thought that I might also wan the Android application to send other signals, or to take part in a two way protocol.  I admit I don’t know exactly how this will evolve but certainly want to leave my options open.
So attached is a simple PHP script that receives an action parameter from the caller (user web access or programmatic Android web access).  The “action” received is passed to the Android device on the local LAN, where it is parsed and actioned.
I should mention that I do run a web server on my local network, which is accessible from the outside world.  Internally I run Citrix with several VM’s for things like PlexServer, Minecraft, Windows and Linux development and a Transmission server, so the setup of a PHP script was also trivial.
PHP web script is attached.

Step #4 – Putting it All Together

The video below is the best way to show how all the parts came together.