OpenWRT Garage Door Controller

Written by Justin Goetz -

This is a quick tutorial for turning an OpenWRT router into a garage door controller. In this tutorial, I will be using the MT300N from GL-Inet to control my garage door over WiFi.

First, you'll need to SSH into the router. We need to edit the file /etc/rc.local. In this file I will put the following lines before exit 0:

/bin/echo 44 > /sys/class/gpio/export
/bin/echo "out" > /sys/class/gpio/gpio44/direction

The first command enabled GPIO pin 44. The 2nd line sets the GPIO port as "output", what we will use to control the relay. Now reboot the router.

Next, lets wire up the relay to the router. For my MT300N router, I used GPIO port 44 (labeled as LINK4 on the router board). Conect GPIO pin 44 to the "IN" pin on the relay. Now, connect GND to GND on relay, and connect the 3.3v pin on the router to the VCC pin on the relay. Here is a wiring diagram:

Now to test if it works, run the following commands. To turn the relay ON, run:

/bin/echo "1" > /sys/class/gpio/gpio44/value

The green light on the relay module should turn on, and you should hear a click. Now to turn the relay off, run:


/bin/echo "0" > /sys/class/gpio/gpio44/value

and the green light will turn off. If this works, your relay is wired correctly.

Now we need to install PHP to run the commands from a web interface. Run the following commands in order to install PHP to your router.

opkg update
opkg install php5 php5-cgi

Now edit /etc/config/uhttpd to enable PHP. Right below the first block of text, add the following lines:

        option interpreter '.php=/usr/bin/php-cgi'
        option index_page 'index.php index.html'

And now restart uhttpd.

/etc/init.d/uhttpd restart

Now lets create a quick script to turn the relay on, wait 1 second, then turn the relay off again. This simulates someone pressing a button to make the garage door open. I wrote this quick and dirty bash script to do just that. I saved this file to /root/garage.sh

#/bin/ash
/bin/echo "0" > /sys/class/gpio/gpio44/value
sleep 1;
/bin/echo "1" > /sys/class/gpio/gpio44/value

And lastly, lets create the quick PHP page to run this shell script. I put this file in /www/garage.php. Here is a link to the script: https://www.justingoetz.net/files/garage.php.txt.

Lastly, we need to wire the relay to the garage door opener itself. This process in concept is simple, you just need to find the two screw terminals on your garage door opener that connect to the garage door button, and wire them to the NO and COM ports on your relay.

Now, when I navigate to http://router-ip-here/garage.php, I can activate the relay, opening my garage door.

A picture of the final setup:

Demo:

Comments

Written by etanayewa -

http://price-of-levitra-20mg.mobi/ - price-of-levitra-20mg.mobi.ankor <a href="http://buyventolin-online.mobi/">buyventolin-online.mobi.ankor</a> http://buylevitrageneric.mobi/
Written by efuwojac -

http://price-of-levitra-20mg.mobi/ - price-of-levitra-20mg.mobi.ankor <a href="http://buyventolin-online.mobi/">buyventolin-online.mobi.ankor</a> http://buylevitrageneric.mobi/
Written by obehihaz -

http://price-of-levitra-20mg.mobi/ - price-of-levitra-20mg.mobi.ankor <a href="http://buyventolin-online.mobi/">buyventolin-online.mobi.ankor</a> http://buylevitrageneric.mobi/
Written by uzagusipuh -

http://price-of-levitra-20mg.mobi/ - price-of-levitra-20mg.mobi.ankor <a href="http://buyventolin-online.mobi/">buyventolin-online.mobi.ankor</a> http://buylevitrageneric.mobi/
Written by unuqimicima -

http://price-of-levitra-20mg.mobi/ - price-of-levitra-20mg.mobi.ankor <a href="http://buyventolin-online.mobi/">buyventolin-online.mobi.ankor</a> http://buylevitrageneric.mobi/
Written by omnohajaodura -

http://price-of-levitra-20mg.mobi/ - price-of-levitra-20mg.mobi.ankor <a href="http://buyventolin-online.mobi/">buyventolin-online.mobi.ankor</a> http://buylevitrageneric.mobi/
Written by auxmiqcap -

http://price-of-levitra-20mg.mobi/ - price-of-levitra-20mg.mobi.ankor <a href="http://buyventolin-online.mobi/">buyventolin-online.mobi.ankor</a> http://buylevitrageneric.mobi/
Written by AenligeRance -

This condition is pretty limited by the reproductive system and could have several causes for example a response to injury or abnormal the circulation of blood inside testicles. He is content, along with the complete opposite of our thoughts later years has in store for us. <a href="http://www.generiqueviagrafr.fr/ou-acheter-viagra-suisse">http://www.generiqueviagrafr.fr/ou-acheter-viagra-suisse</a>
Written by kamagra gold -

kamagra 100mg reviews <a href="http://kamagradxt.com/">kamagra oral jelly 100mg sildenafil citrate</a> kamagra oral jelly kaufen wien <a href="http://kamagradxt.com/">buy kamagra online</a> kamagra 100mg tablets usa http://kamagradxt.com/ kamagra oral jelly buy online