Introduction: Open Source Garage Door Controller / Monitor

Monitor and control your garage doors from the web (including mobile devices) via a Raspberry Pi.

This project provides software and hardware installation instructions for monitoring and controlling your garage doors remotely (via the web or a smart phone). The software is designed to run on a Raspberry Pi, which is an inexpensive ARM-based computer, and supports:

  • Monitoring of the state of the garage doors (indicating whether they are open, closed, opening, or closing)
  • Remote control of the garage doors
  • Timestamp of last state change for each door
  • Logging of all garage door activity
  • Password protection
  • SMS/email alerts when your doors have been open for a specified amount of time.

Step 1: Hardware Requirements

You'll need the following hardware.

Step 2: Install the Magnetic Contact Switches

The contact switches are the sensors that the raspberry pi will use to recognize whether the garage doors are open or shut. You need to install one on each door so that the switch is closed when the garage doors are closed. Attach the end without wire hookups to the door itself, and the other end (the one that wires get attached to) to the frame of the door in such a way that they are next to each other when the garage door is shut. There can be some space between them, but they should be close and aligned properly, as in the picture.

Step 3: Install the Relays

The relays are used to mimic a push button being pressed which will in turn cause your garage doors to open and shut. Each relay channel is wired to the garage door opener identically to and in parallel with the existing push button wiring. You'll want to consult your model's manual, or experiment with paper clips, but it should be wired somewhere behind the motor, as shown in the image.

Note: In some newer garage door controllers, it may not be as simple as wiring in the relay wires as if it were just another push button to open and close the doors. Some newer garage door controllers send signals over the wire beyond just closing the circuit when the button is pressed. In this case, you may have to get a bit creative. One of my buttons was like this, and I got around the problem by soldering my wires into circuit board inside button itself, so that my relays would trick the electronics in the button into thinking the push button was physically pressed. This may void warranties, etc., etc., etc., but it worked for me.

Step 4: Wiring It All Together

The following diagram illustrates how to wire up a two-door controller. The program can accommodate fewer or additional garage doors (available GPIO pins permitting).

This wiring diagram was put together for a RPI Model A, but it will undoubtedly work for a Model B as well. You just may need to change the GPIO pins around slightly and update the config file accordingly.

Step 5: Software Installation

    1) Install Raspbian onto your Raspberry Pi

    Here are some reasources for installing the OS on an RPI:


    2) Configure your WiFi adapter (if necessary).

    3) Install the python twisted module (for the web server)

    From the command line, execute:

    • sudo apt-get install python-twisted

    4) Install the controller application

    I just install it to ~/pi/garage-door-controller. You can install it anywhere you want but make sure to adapt these instructions accordingly. You can obtain the code via SVN by executing the following:

    5) Edit the config.json file

    Door settings

    You'll need one configuration entry for each garage door. The settings are fairly obvious, but are defined as follows:

    • name: The name for the garage door as it will appear on the controller app.
    • relay_pin: The GPIO pin connecting the RPi to the relay for that door.
    • state_pin: The GPIO pin conneting to the contact switch.
    • approx_time_to_close: How long the garage door typically takes to close.
    • approx_time_to_open: How long the garage door typically takes to open.

    The approx_time_to_XXX options are not particularly crucial. They tell the program when to shift from the opening or closing state to the "open" or "closed" state. You don't need to be out there with a stopwatch and you wont break anything if they are off. In the worst case, you may end up with a slightly odd behavior when closing the garage door whereby it goes from "closing" to "open" (briefly) and then to "closed" when the sensor detects that the door is actually closed.

    You can add additional doors (if you have a larger relay and sufficient GPIO pins) by adding additional entries in the "doors" section.

    There are some additional settings for notifications and security. These are housed under the smtp and site sections, respectively.

    Security:

    You can specify a username and password by changing the corresponding fields here. Sorry, the password is not encrypted. If someone wishes to fork the program in GitHub to fix that, I'd happily incorporate the change and credit the developer.

    Email/SMS Notifications

    The smtp section of the config file allow the software to be configured to send email notifications. First, you'll need to configure the smtphost, smtpport, username, password, and smtp_tls settings to the SMTP servers you use in order to send outgoing email. If you use GMail, and you're using the special kind of security where it sends you text message verifications when you log in from other machines, you'll need to set up an "Application password" and use that.

    Finally, set the email address to send the notification to. If you want to be notified via SMS, you'll need to figure out what email address are provided by your carrier to forward to SMS. For AT&T, it's <yournumber>@mms.att.net

    The time_to_wait field is the number of seconds before sending out a notification. For some reason it's always off by 1 minute and 40 seconds. I don't know why but I also haven't bothered looking into it as I never really cared. Perhaps I'll get around to it, or maybe one of you can make the change for me.

    6) Set the controller to launch at startup

    Simply add the following line to your /etc/rc.local file, just above the call to "exit 0":

    • (cd ~pi/garage-door-controller; python controller.py)

      Step 6: Using the Controller Web Service

      The garage door controller application runs directly from the Raspberry Pi as a web service running on port 8080. It can be used by directing a web browser (on a PC or mobile device) to http://[hostname-or-ip-address]:8080/. If you want to connect to the raspberry pi from outside your home network, you will need to establish port forwarding in your cable modem.

      When the app is open in your web browser, it should display one entry for each garage door configured in your config.json file, along with the current status and timestamp from the time the status was last changed. Click on any entry to open or close the door (each click will behave as if you pressed the garage button once).

      Home Automation

      Participated in the
      Home Automation