Raspberry Pi Garage Door Opener

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.
Raspberry Pi Garage Door Opener
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:
http://raspberry.mythic-beasts.com/raspberry/images/raspbian/
For full instructions on installing an OS to your PI and other images, visithttp://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.

Step 2: Setup Wifi via the command line

The next step is to setup your wifi from the command line. This will allow us to control the pi remotely via ssh.
Here is a great guide for Wheezy:
http://www.howtogeek.com/167425/how-to-setup-wi-fi-on-your-raspberry-pi-via-the-command-line/
Since we are using the Model A with only one usb port, you will need to set up the configuration with your keyboard, shutdown the pi, insert the Wifi Dongle and then start it backup. This may take a little guess and check.
The command to shutdown the pi is: sudo shutdown -h 0
If all goes well, once you set it up and reboot, your pi will be given an IP address by your router. You can find this IP address by either hooking the pi up to an hdmi monitor and looking at the boot log, or logging in to your router and looking at the DHCP table.

Step 3: Install Software

Now that we have the wifi setup, we are going to download and install the necessary software to our pi. Since our usb port is now being used by the wifi dongle, we will do this via ssh.

If you are using Ubuntu, open up the terminal and type ssh [email protected][Your Pi’s Ip address]. If you are using Windows, you can download Putty. On OSX, you can also just ssh from the terminal. Again, the default password on Wheezy is raspberry.
Once your a logged in, download, compile, and install Wiring Pi. This software allows us to control the GPIO pins on the pi. Here is a step by step guide for that:
http://wiringpi.com/download-and-install/
Once Wiring Pi is installed, you will want to install Apache and PHP via these commands:

$ sudo apt-get update
$ sudo apt-get install apache2 php5 libapache2-mod-php5
Once this is done, you will have a working webserver! To verify that, just type in your pi’s ip adress in a browser. You should see Apache’s default website which says “It Works!”.

Step 4: Upload the Garage Opener Website

Now that we have a working webserver, we are going to upload a website to it. I’ve created a very basic one that will trigger the relay we will wire in the next step.
Here are two ways to do that:
Ubuntu
Dowload the GarageOpener.zip to your desktop. Open up your terminal, and type the following commands:
$ ssh [email protected][YOUR PI’S IP ADDRESS]
$ sudo rm /var/www/index.html
$ sudo chown pi:root /var/www
$ exit
$ cd ~/Desktop
$ scp GarageOpener.zip [email protected][YOUR PI’S IP ADDRESS]:/var/www
$ ssh [email protected][YOUR PI’S IP ADDRESS]
$ cd /var/www
$ unzip GarageOpener.zip
$ rm GarageOpener.zip
Any OS
Download Filezilla. Using Putty or another ssh terminal:
$ ssh [email protected][YOUR PI’S IP ADDRESS]
$ sudo chown -R pi:root /var/www
Raspberry Pi Garage Door Opener
Start filezilla. Log into the raspberry pi with these credentials:
Host: sftp://[YOUR PI’S IP ADDRESS]
Username: pi
Password: raspberry

Then upload all of the files from GarageOpener.zip to /var/www. Also, delete the existing index.html.

For more detail: Raspberry Pi Garage Door Opener

Scroll to Top
Read previous post:
Home Automation Raspberry and Phidgets

In previous tutorials we used Raspberry Pi to drive Phidgets InterfaceKit. We have also set up a web server on...

Close