****PLEASE NOTE: While this system does nothing more than add an additional “button” to open/close the garage and does nothing to defeat the safety IR Beam on the door, I can’t say for sure whether the system is completely safe as the garage door can open or close via remote command from anywhere based on an internet connection.****

A WeMo is basically a WIFI/remote controlled switch. You plug it into the wall and then something else into the WeMo (e.g., Christmas tree lights). Then you get the WeMo joined up to your WIFI at home and install the App on your iPhone/Droid and you can then turn the WeMo on or off from your phone. Big deal, right?. Well, I bought one this past summer as I installed a small fountain on my porch that did not have a switch…so before the WeMo I had to crawl under the porch to plug/unplug it from the extension cord every time I wanted to enjoy the peaceful surrounds of my Zen porch. But putting a WeMo down there meant I could turn it off and on from my phone.

But the WeMo is a bit more interesting than that. It can also have a set of rules for each WeMo switch. I created a rule to always turn the fountain off at midnight if someone left it running. And I wrote another to run the fountain one hour a day in the morning to ensure the water did not get gross or become a mosquito estuary if no one ran it for enjoyment. Now you get how these things are kind of cool. right?

But WeMo is even cooler as you can hook a WeMo switch into IFTTT.com (If THIS then THAT). IFTTT is an internet automation system. So I have a rule on IFTTT to look for any picture someone posts to FaceBook which I am tagged in the image. If IFTTT finds an image I am tagged in on FB, it copies the image to a folder in my Dropbox account which allows me to keep an archive of Facebook images. You could use IFTT and a WeMo for a rule like “If I arrive home, turn ON the WeMo for the fountain” which will turn on the fountain when I get home.

I bought some more of these WeMo switches and started using them around the house for other things. By now I was really finding fun things to do with the WeMo. So I started thinking large. It has always annoyed me that we leave our garage door open all night, sometimes. What if I could use a WeMo to control the door and close it at 11pm every night? I started to think about how to do it and realized it would not be as simple as the a fountain. Why?

Well, the WeMo is not set-up all that well to work with a garage door as they work differently. The WeMo is more like a light switch - it is ON or OFF and it has a little light (blue LED) to reflect its state. But a garage door is different - it has a button that toggles the state of the door only. There is no ON or OFF switch for your garage door - just the ability to toggle its state. So how would you connect a device that is ON or OFF to a toggle device?

What’s worse is that the garage door system works by shorting two contacts on the motor for a second or so which tells the door to change states (that’s what happens when you press the button for your garage door). The WeMo device has no sense of “toggle”. The WeMo is just an ON or OFF device.

So how would you connect the two and make them work together? What I wanted was to tell the WeMo to change states from my iPhone and have that trigger the garage door. So I would need to program something in between the WeMo and the garage door to see that the WeMo changed states (from ON to OFF or the other way) and then tell a relay (or transistor) that is attached to the garage door motor to CLOSE for a second and then OPEN again. The CLOSING of the relay would short the contacts on the garage door which would cause it to move. There are simple electronic components that can do this (like a FLIP FLOP). So I could have the WeMo tell the Flip Flop to tell the relay to CLOSE for a second and then OPEN again which would work to get the door to move and change states.

A Flip Flop paired with a relay might have been a good first step but not 100% what I wanted. I wanted a bit more.

The WeMo’s state (whether it is ON or OFF) is something my iPhone/Droid App can see and display to me. Wouldn’t it be great if the WeMo’s state could tell me whether the garagedoor was OPEN or CLOSED? Basically if the door was open the WeMo would be ON and visa versa (garage down, WeMo OFF).

But If I just did the system as I described above with the Flip Flop, there would be no way for the WeMo to know the state of the door with certainty. Sure the WeMo could be told to change states by my iPhone and that state change could trigger the Flip Flop and in turn the relay which would tell the door to change states. But there was no synchronization between the WeMo and the door. And while I could start up the system with everything “in sync” it would quickly become out of sync as there are many things that can open or close the garage besides the WeMo (car remotes, the physical button by the door of my house and also a numeric keypad). So as soon as someone closes the garage with a car remote, the WeMo would have no clue and its blue light would still think the door was open (just an example).

So to make this really work, I would need a way to somehow allow the WeMo to sense the state of the door and stay in sync if indeed something else changed the garage door’s state.

So I opened up a WeMo and separated the high voltage AC relay that controls the power to the load attached (christmas lights, etc) from the low voltage board which has just the WIFI controller part of the WeMo. What I ended up with (the low voltage board) was a small board with 3 leads - Red and Black for power (+5V and ground) and a white wire which was the switch itself. Inside of a WeMo, normally, its WIFI connected computer listens for commands from an iPhone. If it gets one, the WeMo may switch from OFF to ON in which case the white wire would change from 0V (off) to 3.3V (on) which normally “told" the relay on the high voltage board to turn on and send AC power to the chirstmas lights attached. Follow so far?

So if I had "some sort of electronic system that I could program", I could have it look at the white lead of the WeMo and if that lead went from ON to OFF it was time to close the garage door….or visa vera, OFF to ON meant it was time to Open the door.

But what if the door changed state on its own (via a car remote for example). I needed a way to electronically “resync” the WeMo so the WeMo could reflect the new garage door state. Luckily the WeMo does have a mechanical switch on it so that a person can just walk up to a WeMo and press the button (instead of using the App on your iPhone). The switch simply connects a part of the WeMo circuit board to 0V when it is pressed (the switch is normally at +5V). So if I soldered in a wire to the physical push button switch on the WeMo and connected it up to “some sort of electronic system that I could program”, I would have a way to tell the WeMo electronically to change states by connecting that wire to 0V briefly. So now I can “read” the state of the WeMo from the white wire and “change” the state of the WeMo by toggling my soldered in wire (pull it to 0V for a sec and then back to 5V causes the WeMo to change states).

So I needed a way to electronically “see” that the door was OPEN or CLOSED. So I bought a couple of magnetic reed switches like you might see on a security system at a house. One side is a magnet and the other is a switch that will open or close depending on whether the magnet is close. So I mounted one magnet on the garage door and two switches such that when the door was open, the OPEN SWITCH was triggered and the other was tripped for the closed position.

Now I had everything I needed:

1) iPhone Remote Controlled Switch (WeMo)

2) A way to electronically sense the state of the WeMo

3) A way to electronically change the state of the WeMo

4) A sensor to see if the door was OPEN

5) A sensor to see if the door was CLOSED

6) A way to change the state of the garage door (via an electronic relay)

So now I just needed some glue. I looked at a Rasberry Pi but that was overkill. I did not need an operating system, storage, video output, etc. I just needed to tie some logic together to make it all work. So I ended up getting an Arduino UNO Rev 3 board ($35).

The Arduino code is available on Github (https://github.com/cdhutzler/wemogarage). The first section is just setting up some variables. The next section is code that runs one time and is used to just initialize everything like recording the initial WeMo state, etc.

The last section of code is the meat and potatoes. Basically it is a Finite State Machine that knows the state of the door and looks for a trigger to move to the next state - like a command coming into the WeMo or someone pressing one of the more traditional garage door buttons in a car (garage remote). If the state is currently closed, any of the triggers will command the door to change states, thus moving the FSM to the “in between” state and eventually (hopefully) the open state. If another trigger comes in, the FSM moves in the other direction from open to in between to closed. The FSM is also smart enough to move from open to in between to open again in the case that maybe the door failed to close (remember the safety IR beam). 

The FSM also has a method for comparing the state of the door to the state of the WeMo and syncing them which is required if anything other than the WeMo commands the door to change states.

That's about it.

So why bother with all this? Well I can now do things like:

I can get a notification when I am away and the dog walker comes to take care of Lucy as she uses the garage door to get into the house. And when the kids get home, etc, etc.

****PLEASE NOTE: While this system does nothing more than add an additional “button” to open/close the garage and does nothing to defeat the safety IR Beam on the door, I can’t say for sure whether the system is completely safe as the garage door can open or close via remote command from anywhere based on an internet connection.****