Raspberry Pi – Simple Garage Door Opener

Hello everyone. Today I want to show you how you can build your own Garage Door Opener which will allow you to open your Garage Door by simply pressing a button on a website. Pretty cool, huh? What we will basically do is setup a computer controlled push switch/button. A pretty good explanation can be found here.

Okay let´s do this. These are the things you will need:

  • A Raspberry Pi Model B (Plus power adapter, SD card and a LAN cable)
  • Raspbian wheezy as Operating System. You can download it from here.
  • A Raspberry Pi Relay (like this one here) or a transistor (It should work exactly the same but I did not try it out) – I recommend to use a relay since they are not very expensive and you can use them to work with higher currents and voltages. If you use a relay for this project you can reuse the same hardware to create an intelligent AC light switch without making any changes to the hardware. All you would need to do would be to change some fragments of the custom.html code from this post.

Hardware setup:

The hardware setup is pretty simple. Take you Raspberry Pi and connect it to you Raspberry Pi relay like this:

  • Connect one 5V Power Pin to the relay´s VCC Pin
  • Connect one Ground Pin to the relay´s GND Pin
  • Connect the GPIO 17 Pin (You can use any GPIO Pin you want but for this project I used GPIO Pin 17) to the relay´s IN1 Pin


Now connect you relay to your Garage Door Control as if you would add a new push switch/button. Wire the relay like this:

  • Connect one wire from your Garage Door Control to the relay´s COM contact
  • Connect the other wire from your Garage Door Control to the relay´s NO contact

There are some great tutorials out there which explain how to set up electric Garage Door Openers (like this one here) so if you have trouble have a look at them. All Garage Door Openers work pretty much the same.

That´s it. You have finished the Hardware setup.

Software Setup:

Now the Software Setup. This will be easy too.

The first thing you need to do is to update your Raspberry Pi:

sudo apt-get update
sudo apt-get upgrade

Now you need to download WebIOPi:

wget https://webiopi.googlecode.com/files/WebIOPi-0.6.0.tar.gz

Unpack the archive file:

tar xvzf WebIOPi-0.6.0.tar.gz

Change into the newly created directory:

cd WebIOPi-0.6.0

And run the WebIOPi setup: (This will take some time)

sudo ./setup.sh

After the setup has finished you can run WebIOPi by running the following command:

sudo python -m webiopi

Now you should be able to access the WebIOPi web interface by entering the following URL into your Browser: (Default User: webiopi and Default Password: raspberry)


Now end the execution of WebIOPi by hitting Ctrl+C.

Since we want WebIOPi to be always available we need to run the below command to make sure that it will be started at boot:

sudo update-rc.d webiopi defaults

Now reboot your Raspberry Pi:

sudo reboot

If you can access WebIOPi´s web interface after the reboot everything is working correctly.

The next thing I did was to create a directory where I store my custom made code for my project:

sudo mkdir /usr/share/webiopi/htdocs/custom

And here is my code:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content = "height = 300, width = 300, user-scalable = no, initial-scale = 1, maximum-scale = 1" />
<title>Garage Door Opener</title>
<script type="text/javascript" src="/webiopi.js"></script>
<script type="text/javascript">

webiopi().ready(function() {
content = $("#content");

function setGPIO17()

function changeButtonPressed()

function changeButtonReleased()

function RunFunctions()
setTimeout(changeButtonReleased, 500);

function sleep(milliseconds)
var start = new Date().getTime();
for (var i = 0; i < 1e7; i++) {
if ((new Date().getTime() - start) > milliseconds)

<body bgcolor="#191f2f">
<div id="content" align="center">
<font face="verdana" color="white">
<h1>Garage Door Opener</h1>
<input type="image" style="outline: 0" id="PowerButton" src="power_off.jpg" onclick="RunFunctions();">

So, how does the above code work? Well, it will set GPIO Pin 17 to OUT which will allow the electric current to power our relay. When the relay is powered it will short the contacts COM and NO closing the electric circuit resulting in our Garage Door to either open or close. Next the Javascript code will sleep for 1 second before setting the state of GPIO Pin 17 to IN again. This will result in our relay getting un-powered thus opening the electric circuit between COM and NO and closing the electric circuit between COM and NC.

To access the custom.html page simply enter the following URL into your Browser:


Well, that´s it. Now everything is ready to use. Pretty simple isn´t it?


Please make sure to secure the network you are using to access this control website and make sure to change the user and password of webiopi to make sure that only you can open your Garage Door and to prevent theft. Please take care not to damage your belongings when trying to set this up. I will not take responsibility for any damages or problems when you use these instructions to set this up for yourself. Do this on your own risk. And please try not to get hurt.

Of course you can have my source code as always. You can find it here.

I hope my post was useful for you and I hope to see you again next time 🙂









https://raspbeerypi.wordpress.com/2014/01/15/webiopi-smartphone-computer-verbindung/ (german)



4 thoughts on “Raspberry Pi – Simple Garage Door Opener

  1. jacob says:

    Didn’t know garage door can be opened this way over the web with the help of a program. Innovative, quite an interesting post. Thanks for sharing.

  2. Martilyo says:


    So far I have followed everything on the software side. Your custom code refers to power_on.jpg and power_off.jpg. Could you please post these files so I can have an exact copy of what you did with this? I would appreciate it.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: