Internet garage port opener
When I get home from work on my bicycle the process of parking the bike in the garage has been the following.
- Unlock the front door to the house.
- Turn off the alarm.
- Open the garage door via a remote control.
- Park the bike in the garage.
The garage port motor
The motor used in the garage has two connectors that works like a push button if they are connected together. When connected the state of the port is toggled and that means if its closed it will open and if its open it will close. I have tried to shorten my process of getting into the garage with the help of these connectors and some hardware and software.
My first shot at this was to use an Arduino Uno hooked up with an RFID reader. This solution would make it possible to jump off the bike infront of the garage port and touch the RFID reader with a granted RFID module. I used a Mosfit transistor to try to hook up the motor that opens the port. It worked fine when the Arduino Uno was fed with power from a computer but stopped working when a USB power supply was used for power. I tried lots of other solutions to make it work with my mininal electricity knowledge but the port remained closed.
After some time of licking my wounds I received my order of the Kickstartered project Onion Omega2 in the mailbox. It a small linux computer and heres the quotation from its kickstarter campaign.
It combines the tiny form factor and power-efficiency of the Arduino, with the power and flexibilities of the Raspberry Pi.
A nice thing is that it creates its own wifi access point and that you can access it via SSH. When I was playing with the Omega2 I also ran into a video from ItKindaWorks where he was showing how he was solving the same problem I had. In his solution he used a relay module that isolated the garage motor from the electricity. I bought one of this modules and connected it to the Omega2 and could get the garage port to open! SUCCESS :)
(The relay module would have made my first take on this problem work. but I contionued on the Omega2 route.)
This is the shell command I ran on the Omega2 to toggle the garage port.
gpioctl dirout-high 0 && sleep 1 && gpioctl dirout-low 0
The command sets the IO pin 0 on the Omega2 to high then waits for one second and then sets the pin 0 to low. This series mimic a push button and it toggles the current state of the garage port. If the port is closed it will open, if its fully open it will close, if the port is closing/opening it will stop and if it was closed on the way down it will go up and vice versa.
After a run of testing I decided to advance the Omega2 solution with a reed switch sensor to know if the port was closed or open. Add the MQTT protocol for controling the port and also to know its current status. Add a web page to open/close the port from anywhere and also know if the port is open or closed.
One Onion Omega2 — the heart of the project
One Onion Omega dock — expose the IO pins and USB power socket
One relay modul — separates the power of the Omega2 and the garage port
One reed switch — indicates if the port is open or closed
One magnet — Sets the reed swith high or low
Four male-female cable ties — Connects the relay module and reed switch to the Omega dock
One USB charger — powers the Omega2
One bipolar cable — connects the relay module to the motor thats opens the garage
mosquitto — MQTT client.
MQTT is a lightweight publish / subscribe protocol that makes it easy to send out event from one or more publishers where one or more subscriber can lisen to the events.
An account at a MQTT broker (Shiftr.io in my case).
Web page with the current status of the garage port and where it can be toggled.
Connect to the Omega2 via SSH
opkg install mosquitto mosquitto-client libmosquitto
#Make the scripts executable
chmod +x cmd.sh
chmod +x status.sh
Add your MQTT information to the two files. cmd.sh only subscribe to the topic and needs only read access while status.sh publish and need write access to the topic.
# MQTT SETTINGS
Add the two files to /etc/rc.local to make the files run when the Omega2 boots.
# Put your custom commands here that should be executed once
# the system init finished. By default this file does nothing.
ash /root/cmd.sh &
ash /root/status.sh &
If everything is working correctly you should now see status events start flowing through the topic. Here is how my topic looks. https://shiftr.io/morgan/garage
To toggle the garage port we have to send a
toggle event to the topic. You could do this manually via the mosquitto client.
mosquitto_pub -h $host -u $user -P $password -p $port -t $topic -m "toggle"
I have created a little Ruby program that expose a web page that are connected to the MQTT broker. From the web page a toggle event can be trigger via a button and the current status of the garage port is shown. Below are two pictures showing the two possible states of the web page.
Take 2.1 — Kronaby watch integration
The cool thing is that you can use it together with IFTTT to controll things in your surrounding. I make use of the webhook applet in IFTTT to send a http Post request when I press one of the buttons on the side of the watch. The request is triggering the MQTT toggle event via the same functionality as the submit button on the web page build in Take 2.
Here´s a video of the final result. https://www.youtube.com/watch?v=N_0D8SKBXrE