Hello Everyone!

This instructable explains how I setup a Raspberry Pi to open my garage door using a smarthphone. While this has been done before, I thought I'd post my solution. This was my first hardware project and instructable ever and I'm sure I made some mistakes. So, when you find one let me know! 

Project Overview:
What we will be doing is turning the Raspberry Pi into a small web server. When you access the webserver from your browser of choice, you will have a big button that triggers the garage door via a relay. We will wire a very basic circuit to the Pi's GPIO pins and upload a website that triggers the circuit. When the relay is triggered, it closes the circuit hooked up to the garage motor and opens the garage.

Why would anyone want to do this?
Well, my garage door opener was broke and this was cheaper than replacing the other system. As an added plus though, you could wire up additional sensors and be able to make sure your garage is closed remotely if your were so inclined.

Shopping List:
I consider myself pretty cheap, and I tried to keep the costs minimal. All of the items are available on prime.

1.) Raspberry Pi - Model A - $32

2.) Wifi Adapter - $10

3.) PSU - $5

4.) 5v Relay - $6

Total: $53.00

You will also need an sdcard >= 2GB and some wires, but I had extra of each.

Step 1: Install and Optimize Rasbian (for our purposes)

This first step is to install an operating system to your rpi. I'm a bit of a debian fanboy, and had an extra 2GB sdcard, so I went with a shrunk version of Wheezy. The image I used can be found here:


For full instructions on installing an OS to your PI and other images, visit http://www.raspberrypi.org/downloads.

On Ubuntu, I used gparted to format to fat32, and dd to write the img.

After you install the OS, plug in a usb keyboard and hook up the raspberry pi to a monitor. Assuming you are using Wheezy, on the first boot rasp-config will automatically run. You should use this tool to stretch the parition and enable ssh (under the advanced menu on newer versions I believe).

After I installed my img, I also removed the GUI to free up some space. (If you have a large SD, you can skip this.) To do this type these commands:

$ sudo apt-get remove --purge x11-common
$ sudo apt-get autoremove

This removes all packages that depend on X11 which is pretty much all of the GUI.

<p>Works great! Just wish it would work outside of my WiFi. I don't want to open any TCP ports for security reasons. </p><p>Great project!</p>
Hi everyone. I have this project done but can't get the garage door to open. When I hit the button on my smartphone I can see the wifi adapter light activate as well as the indicator light on the relay. I do not hear the relay click when this occurs. I am using the provided canakit 2.5 amp power adapter so i dont think this is an issue of lack of power. Your input and ideas are welcome<br> Thank you<br>
<p>does anyone know how to change the code for raspberry pi II? I have the raspberry pi 2 and what file do I go into to change the PIN numbers?</p>
<p>I receiving the following message</p>Not Found<p>The requested URL / was not found on this server.</p>Apache/2.4.10 (Raspbian) Server at 192.168.1.XXX Port XXnot sure what i am missing everything went well until i got to test the page
<blockquote>Most relays including the one I purchased, operate like this - when the signal is ON the circuit stays off. When the signal is OFF then the circuit is on.</blockquote><p>I'm totally new to this and don't understand this part. I assume you have either NO or NC terminal connected to the garage door opener. If normally when the signal is ON, the circuit stays off and vice versa, can't you just switch the garage door connection from NO to NC or NC to NO?</p>
<blockquote>Most relays including the one I purchased, operate like this - when the signal is ON the circuit stays off. When the signal is OFF then the circuit is on.</blockquote><p>I'm totally new to this and don't understand this part. I assume you have either NO or NC terminal connected to the garage door opener. If normally when the signal is ON, the circuit stays off and vice versa, can't you just switch the garage door connection from NO to NC or NC to NO?</p>
<p>i am using rasp pi 2 for this - added VNC, VLC and smoother items. The server however isn't really populated and only gives me the index. I plan on adding other prefer to it as well. but need to have the server for IP/WIFI control first. Any help is great.</p>
<p>I need the software package/code for raspberry pi 2 version 1</p>
<p>Can anyone tell me why this happens. If the power in the house blinks, or goes out and comes on later, as the RasPi reboots the door will open with out a command from me. There have been times I come home and garage is open and i didnt do it, but can see the power blinked or went out. </p>
<p>See step #6 for explanation and potential solution.</p>
<p>This Is My Finished Garage Automation System.</p><p>Ended up installing RPi-Cam-Web-Interface and adding Buttons to it.</p><p>This come with a authentication page built in.</p><p>Just added a Cron job to automate turning on and off the christmas lights!</p><p>Great Fun these boxes.</p>
<p>What is the difference between your relay module and this one? other than the obvious 2 additional channels?</p><p><a href="http://www.microcenter.com/product/437826/4_Channel_5V_Solid_State_Relay_Module_BoardOMRON_SSR_AVR_DSP_Arduino" rel="nofollow">http://www.microcenter.com/product/437826/4_Channe...</a></p><p>Can I use it in the same fashion as you have without the need of additional power sources or other parts? Yours seems so simple, but I read others who used this part had to provide additional transistors and what not.</p>
<p>I deleted the index under .git and replaced it with the new index.php and I am still getting the following message</p>It works!<p>This is the default web page for this server.</p><p>The web server software is running but no content has been added, yet.</p><p>Does anyone know what I am doing wrong?</p><p>Thanks</p>
<p>My guess would be that you need to configure the PHP extension on the web server. In Apache, the httpd.conf file has this line</p><p>&lt;IfModule dir_module&gt;<br> DirectoryIndex index.php index.php3 index.html index.htm<br>&lt;/IfModule&gt;</p><p>You need to make sure the right file names / extensions are in there.</p>
I managed to use this Instrucables and one from PiMyLife to have video on same page as garage door button .<br><br>http://www.instructables.com/id/Raspberry-Pi-Garage-Door-Opener-with-streaming-vid/
<p>Super cool. Thanks for sharing!</p>
<p>i want to control a relay from openelec so i can remotly turn off my lights with a press of my remote will this work with openelec?</p>
<p>Good article. Now I can control my garage door using a web-interface. A few additional things I did was to password protect the page, and add mechanism for knowing the state of the door (open or close).</p>
<p>How would you create a password to protect the website?</p>
<p>Use a simple php script. Something like this.. </p><p><a href="http://www.phptoys.com/tutorial/creating-password-protection.html" rel="nofollow">http://www.phptoys.com/tutorial/creating-password-...</a></p>
Hi <br>I have a question i'm doing a university project and need just a door lock to open and close via smart phone more like an web app open, close nothing to fancy, but i only want it open close via battery so do i need a relay and how can i by pass it ? <br> <br>Thanks
<p>Would this interfere with a multi-button Wall Panel where you can not only open and close the garage door, but also turn on light, or place your unit in lock mode? If i had a single button opener on my wall this would be straight forward. Please advise if you have any more insights here. thanks and great job! this is pretty darn cool.</p>
<p>If you have a multi-button wall opener, it probably connects by two wires to the garage door opener. You can connect your relay to the same two terminals on the garage door opener. It seems like when you press a button on the wall opener, it sends pulses to the garage door opener, but if you just short those terminals by closing your relay for a second or so, it makes the door open or close. The wall opener will still work normally, including the light switch.</p>
I having a Chamberlain multi LCD wall button with motion sensor. It also tells if power has been restored or battery backup is charging. Does time and temp and lights.<br><br>I went directly to the ceiling unit. I think the wall button LCD doesn't like being shorted. I sometimes get a message on the LCD saying something is miss wired. So I may need to add leads to actual button or solder leads on a wireless remote.<br><br>Anyone have any thoughts?<br>
<p>If you do not like to control your device via web interface, you can try Android app</p><p><a href="http://www.instructables.com/id/RaspberryPi-Android-Switch-Home-automation/" rel="nofollow">http://www.instructables.com/id/RaspberryPi-Androi...</a></p><p>Keep original setup but skip web-server part.</p>
Great instructable!<br>I have been using my Raspberr Pi controlled garage door for months without any issues.<br>I am now trying to understand the code but I am struggling. I deleted the original images uploaded to /var/www and uploaded my owm image but I still get the gray button. So I am confused what it's doing.<br><br>Would some one be kind enough to give me a line by line rundown of the code in index.php so that I can understand and learn how everything fits together.<br><br>Many thanks in advance.<br><br>Joe
<p>I know this is an old thread - but I am trying to get rid of the Gray button and make it prettier. Anyone have any idea how to do that?</p>
<p>Thank you for the instructions. I used them to assemble the device and wrote small customizable service that can be run on the device and controlled remotely via android app. </p><p><a href="https://github.com/sshlyk/switch-server" rel="nofollow">https://github.com/sshlyk/switch-server</a></p><p><a href="https://github.com/sshlyk/switch-android" rel="nofollow">https://github.com/sshlyk/switch-android</a></p><p>It is very flexible and you can configure separate relays to act as a switch that turns something on/off or you can make it pulse and use it as garage door opener. All devices are seen on in the app and you can controled individually.</p><p></p>
Can you integrate this http://pimylifeup.com/raspberry-pi-webcam-server/
I made this, worked the first time.<br><br>How would I merge this so video is on the same screen as the Garage button? http://pimylifeup.com/raspberry-pi-webcam-server/
<p>What about muilti function wall buttons that do lights and other stuff?</p><p>I saw on another site that said open/close is just shorting the pair. Lights put a Capacitor in series, etc</p>
Hi. Can i do this without internet connection Or with a Bluetooth?
<p>Worked like a charm!</p><p>I have an IP camera in the garage and added it to the web page, just above the button. </p>
<p>hello,</p><p>i am new to linux and the Pi but I have followed your instructions thru step 4.and all seemed to work but when I go the the page I do not have button just a blank page which is titled &quot;Garage Opener&quot; . I am not sure what to try . Can you advise me?</p>
<p>sorry, I figured it out . on to step 5</p>
<p>Can you advise me on how you got this to work? I am having this issue as well.</p>
<p>AWESOME INSTRUCTABLE!! thank you . I would like to add an older logitech orbit webcam i have laying around to the webserver. is this possible and where do i start? </p>
<p>Well, I will share my Index and others files, as I added 2 relay to close door, you still need to make pin work at the start, also I have not yet tested, but trigger's working and returning the 1 and 2 </p><p>&lt;?php <br> if(isset($_GET['trigger']) &amp;&amp; $_GET['trigger'] == 1) {<br> error_reporting(E_ALL);<br> exec('gpio write 7 0');<br> usleep(1000000);<br> exec('gpio write 7 1');<br>}<br> else if(isset($_GET['trigger']) &amp;&amp; $_GET['trigger'] == 2) {<br> error_reporting(E_ALL);<br> exec('gpio write 2 0');<br> usleep(1000000);<br> exec('gpio write 2 1');</p><p> }<br>?&gt;<br>&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br> &lt;head&gt;<br> &lt;title&gt;Garage Opener&lt;/title&gt;<br> &lt;link rel=&quot;apple-touch-icon&quot; href=&quot;apple-touch-icon-iphone.png&quot; /&gt;<br> &lt;link rel=&quot;apple-touch-icon&quot; sizes=&quot;72x72&quot; href=&quot;apple-touch-icon-ipad.png&quot; /&gt;<br> &lt;link rel=&quot;apple-touch-icon&quot; sizes=&quot;114x114&quot; href=&quot;apple-touch-icon-iphone-retina-display.png&quot; /&gt; <br> &lt;link rel=&quot;stylesheet&quot; href=&quot;/css/style.css&quot; type=&quot;text/css&quot;&gt;<br> &lt;meta name=&quot;apple-mobile-web-app-capable&quot; content=&quot;yes&quot;&gt; <br> &lt;script type=&quot;text/javascript&quot; src=&quot;/js/jquery-1.10.2.min.js&quot;&gt;&lt;/script&gt; <br> &lt;script type=&quot;text/javascript&quot; src=&quot;/js/script.js&quot;&gt;&lt;/script&gt; </p><p> &lt;/head&gt;<br> &lt;body&gt;<br> &lt;div class='awrap'&gt;<br> &lt;a href='/?trigger=1'&gt;<br> Open<br> &lt;br/&gt;<br> &lt;a href='/?trigger=2'&gt;<br> Close<br> &lt;/body&gt;<br>&lt;/html&gt;</p><p>$(document).ready(function() {<br> $('a').click(function(e) {<br> e.preventDefault();<br> $.get(&quot;/?trigger=1&quot;);<br> $('a').click(function(e) {<br> e.preventDefault();<br> $.get(&quot;/?trigger=2&quot;);</p><p> });<br>});</p>
Please help me. My garage khas two buttons one to open and one to close and I can only open it. How to add another button to use the other relay???
<p>Mine too but i got it worked out. you still need help?</p>
<p>Yes I kind like to know, I have in fact 3 , open close and stop, guessing Im able to relay 2 for close ? and 1 for open </p>
<p>I know I'm a bit late, but links to Image looks not to work, and the ones I found just make a 56Mb drive out of my 2GB SD card anybody have the right files ? and like to share</p>
<p>Perhaps this ?</p><p><a href="http://ftp.jaist.ac.jp/pub/raspberrypi/raspbian/images/2013-05-25-wheezy-raspbian-shrunk/" rel="nofollow">http://ftp.jaist.ac.jp/pub/raspberrypi/raspbian/images/2013-05-25-wheezy-raspbian-shrunk/</a></p>
<p>Im a bit late to this, but like to make it, but I look not to be able to download the <a href="http://raspberry.mythic-beasts.com/raspberry/images/raspbian/" rel="nofollow">http://raspberry.mythic-beasts.com/raspberry/images/raspbian/</a> I did find the noobs image but it need a lot bigger SD card than the 2GB anybody have the Image or advice ?</p>
<p>I made this and connected it to my Chamberlain garage door opener today. It works great.<br><br>I used an old internal CD-ROM audio cable to connect the Pi to the relay. I took off one end and used its crimped-on female pin connectors to attach it to the GPIO header on the Pi. The original four pin header connector on the other end fit perfectly on the relay.<br><br>Next I'd like to add a sensor to tell me if the garage door is open or not. I'm thinking a cheapo magnetic sensor you use to detect open windows and doors in a home security setup, or even just a simple switch attached to a GPIO input. It could show as a green/red indicator on the garage door opener web button.</p>
Hey, I made it too! Thanks for the instructions. I have one issue. I noticed after a few minutes of stand by and I try to return to the page, it times out. I'm wondering if something is going into stand by or something else may be wrong. It takes me a couple tries before I can get back on. Any thoughts?
One thing that just occurred to me is I had it booting to the GUI. Seems to be doing good now after changing it.
The wireless adapter was going on stand by and the following fixed it. BTW, my adapter is a EDIMAX EW-7811Un<br><br>Create the new file<br>$ sudo nano /etc/modprob.d/8192cu.conf<br><br>Add the following <br>options 8192cu rtw_power_mgnt=0<br><br>Then<br>Reboot<br><br><br>Looks like it's working
Correction: /etc/modprobe.d

About This Instructable


258 favorites


More by quartarian: Raspberry Pi Garage Door Opener
Add instructable to: