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.

  1. Unlock the front door to the house.
  2. Turn off the alarm.
  3. Open the garage door via a remote control.
  4. 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.

The motor with connected cables that toggles opening / closing

Take 1

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.

RFID module glued inside a waterproofed box

Take 2

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


Parts when unconnected
And the parts connected
Reed switch and magnet when port is closed


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 ( in my case).

Two scripts and that will interact with the IO pins on the Omega2 and the MQTT broker. I took inspiration from this Stackexchange post when creating the scripts.

Web page with the current status of the garage port and where it can be toggled.


Connect to the Omega2 via SSH

Install mosquitto

opkg update 
opkg install mosquitto mosquitto-client libmosquitto

Download the two scripts and into the /root folder.

cd /root
#Make the scripts executable
chmod +x
chmod +x

Add your MQTT information to the two files. only subscribe to the topic and needs only read access while publish and need write access to the topic.


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/ &
ash /root/ &
exit 0

If everything is working correctly you should now see status events start flowing through the topic. Here is how my topic looks.

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.

The current user interface with the current status of the port and a toggle button

It’s rather straight forward to host on Heroku and if you´d like to play around with the source code you find it on Github.

Take 2.1 — Kronaby watch integration

I’m an owner of a Kronaby watch made by Anima, its an analog looking watch that is connected to your smart phone, making it half smart.

My Kronaby watch with its three push buttons to the right

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.

Happy hacking.