I have seen a lot of neat Raspberry Pi projects on the internet over the past few years. One that I always wanted to try was wiring it up to a Garage Door opener.

After ordering and sitting on the parts forever I finally got around to putting everything together.

I followed Idiot’s Guide to a Raspberry Pi Garage Door Opener by Chris Driscoll for the wiring directions. The link is currently to a Internet Archive cached page since the current site has has been flagged for malware.

Parts List

There are two components, the 2 Channel relay is wired in line with the Garage Door opener button and which when activated completes the circuit and opens the door. The Magnetic Switch is attached to the Garage Door and used to check whether it is open or not.

The Raspberry Pi is running Raspbian and simple to configure. The Wireless USB dongle worked automatically and after attaching to my network I setup two simple python scripts.

The first script, operatedoor.py, energizes pin 40 on the Raspberry Pi for a second to activate the switch and connect the circuit sets the pi to off and clears the state. There is a 1 second delay between turning the pin on and off.

import RPi.GPIO as GPIO
import time

GPIO.setmode(GPIO.BOARD)
GPIO.setup(40, GPIO.OUT)

# Operate door
GPIO.output(40, True)
time.sleep(1)
GPIO.output(40, False)
time.sleep(1)

# Clear state
GPIO.cleanup()

The second script, checkdoor.py, checks the state of pin 8 on the Raspberry Pi which is wired up to the magnetic switch on the garage door itself. If the circuit is complete then the door is closed, or if not complete then the door is open.


#!/usr/bin/python

import RPi.GPIO as GPIO
import time

GPIO.setmode(GPIO.BOARD)
GPIO.setup(8, GPIO.IN)

if GPIO.input(8):
    print 'Open'
else:
    print 'Closed'
time.sleep(1)

GPIO.cleanup()

The project is on Github here.

The Raspberry PI GPIO module made it really simple to the operate the door. In the future I would like to make a small web app with Flask so I can grab the information or operate the door through a http request. This could be from an existing home automation site or something I make myself or maybe something running from my phone.

Right now I am just using SSH to connect from my phone to the Pi and running the operatedoor.py script when I want to open the door from my phone so I would also like to do something with Tasker to send the request to open the door automatically when I am driving up to the door.