Open Source Garage Door Controller / Monitor


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.


    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>

    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

      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).



      • Clocks Contest

        Clocks Contest
      • Creative Misuse Contest

        Creative Misuse Contest
      • Water Contest

        Water Contest

      26 Discussions

      Is it possible to adapt this setup to include an image from a webcamera?
      So that one can verify the status of port visually? Maybe behind the login function..?

      anyone have any suggestions as how i would add a log beneath the buttons, to show a history of when the door was opened, and the IP address used to open it? any nudge in the right direction would be awesome, thank you. great work! this thing is awesome.

      also, after some time now, my second door is not showing an image and the door status says "Unknown" and we have made zero changes, and also dont use the sensors at all, but normally they've never said Unknown, thats for sure.


      1 year ago

      Just finished installing. Overall, I LOVE it, thank you.

      I'm looking into auto-close functionality, hopefully won't be too difficult.

      In your step 3 you mention getting around 'newer' garage door openers (GDO) that don't respond to a contact closure (i.e. the relay connecting the two terminals).

      Another way (that I used on a similar project) was to buy an inexpensive car RF remote and open it up and solder the two wires to the points where the physical button switch was. Now the project 'presses' the button of the remote transmitter and sends a wireless signal to the GDO.

      Another advantage of using a car remote is that most are three channel so a single remote can control up to three doors. I left my remote powered by its 3V coin cell battery but it could also be made to be powered by a 3V supply (or 5V regulated down to 3V or whatever voltage your remote uses).

      I would combine this remote and an NPN transistor (instead of Relays, as suggested by braytonlarson) to eliminate the relay board.

      In my project I also considered (haven't actually done this yet) using a microcontroller, a bluetooth module (or other low power, low cost RF module) and a tilt switch as a door sensor. Using a bluetooth module with built-in microcontroller would work well.

      The idea is to make a battery powered 'tilt module' that would by attached (double sided tape) to the upper panel of a multi-panel garage door. As the door opens the tilt switch is activated (opens or closes depending on physical setup) and that information can be sent via bluetooth (or other RF communication). Likewise as the door closes the tilt switch changes back to the other state. If more info is desired another 'tilt module' could also be placed on the bottom door panel - this would allow sensing of 3 states; door fully closed, door opening/closing, door fully open.

      Been running this in my un attached garage for about 4 months. Works
      great. An open all doors function would be nice as well as code for
      turning lights on and off if you hard wire your lights to a relay board.

      used another instructable to run my lights so I can turn on or off my
      lights with out getting out of my car. Garage door code i have open to
      the "world" but my lights only work if i am on my network/wifi.

      have a 3 stall garage and programed 4 doors in it. Left, Center, Right,
      Service(walk through door). I use the contact switch pin only for the
      service door so i get notified if i left the door open or some one had
      entered the garage. I put it all the hardware in a pvc box along with a
      7 inch touch screen.


      2 years ago

      Thank you.

      Finally something that work for me.

      I want to use your great project but i can not get any of it to work

      2 replies

      Well nothing would work. When I finally figured it out i had to chmod the dir so everything would work. Now my only issue is getting the email part working. I get this message in syslog when email tries to send.

      Feb 9 05:09:18 raspberrypi rsyslogd-2007: action 'action 17' suspended, next retry is Tue Feb 9 05:09:48 2016 [try ]


      2 years ago

      This is a great project. I am building it now. Have you ever thought about putting some time based alerting around it? Say I left the garage open at night, It will check the status and notify me to close the door.

      2 replies

      I figured this would be pretty simple given that you are already getting the door state.

      Jay, Sorry for the late response. The code is set up so that it will send out alerts if the doors are open for a pre-determined amount of time. It sends out emails, but I have it sending it to the email address corresponding to my phone so I get text messages instead.

      Great project and thanks for all the hard work! I'm relatively new to this level of programming, but was able to make it work. The only issue I ran into was accessing the web interface using port 8080 as indicated in the instructions. It appears that it should be port 8081 instead. Also, I didn't add the magnetic sensors and instead would like to add a webcam that can be accessed on the same webpage as the controllers. Any ideas on how to integrate this feature into the project? Second question is how to disable the password prompt if only accessing within home wifi? And lastly any ideas on an alternative to opening a port in my router to access from outside my wifi network, for better security reasons? Thanks again.


      2 years ago

      I have completed the build. It works great. I did have to change a couple of thing though. I deleted the "right" door entry in the config.json since I only have one garage door. Also my relay was activating on startup. It was causing my garage
      to open as soon as the RaspberryPI came online. Not good when there is a
      power outage. I had to change the following in

      42 gpio.output(self.relay_pin, False) <--was True

      72 gpio.output(self.relay_pin, True) <--was False

      73 time.sleep(0.2)

      74 gpio.output(self.relay_pin, False) <--was True

      I like the security login feature, but is would like for it to prompt me for that every time or at least give me a popup warning me that I am about to activate the door.

      I'm having a problem with this as well. My apologies if this is all very basic but this is new to me. Thanks in advance.

      On boot, I get an error:
      [FAIL] startpar: Service(s) returned failure: rc.local ... failed!

      When I try to manually run it I get:

      Traceback (most recent call last):
      File "", line 279, in <module>
      controller = Controller(json.load(config_file))
      File "/usr/lib/python2.7/json/", line 278, in load
      File "/usr/lib/python2.7/json/", line 326, in loads
      return _default_decoder.decode(s)
      File "/usr/lib/python2.7/json/", line 365, in decode
      obj, end = self.raw_decode(s, idx=_w(s, 0).end())
      File "/usr/lib/python2.7/json/", line 381, in raw_decode
      obj, end = self.scan_once(s, idx)
      ValueError: Expecting , delimiter: line 10 column 2 (char 174)

      Thanks again

      4 replies


      The creator of this configuration, AndrewHilliday found an error in the JSON file. He just put up an edit yesterday. I rebuilt my Pi from scratch and started over. Followed his directions, and I was able to get the webpage pulled up on port 8081. I haven't wired anything yet.. Basically have step one done with the website coming up. Check out his page, which is what I followed.

      Good luck!


      yes, he replied to the pm i sent him and i was able to build it last night without the errors as before.

      Same issue on my end. Did you ever figure it out?

      pi@raspberrypi ~/garage-door-controller $ sudo python

      Traceback (most recent call last):

      File "", line 279, in <module>

      controller = Controller(json.load(config_file))

      File "/usr/lib/python2.7/json/", line 278, in load

      File "/usr/lib/python2.7/json/", line 326, in loads

      return _default_decoder.decode(s)

      File "/usr/lib/python2.7/json/", line 365, in decode

      obj, end = self.raw_decode(s, idx=_w(s, 0).end())

      File "/usr/lib/python2.7/json/", line 381, in raw_decode

      obj, end = self.scan_once(s, idx)

      ValueError: Expecting , delimiter: line 10 column 2 (char 188)

      no I haven't. Hopefully the originally, the original poster can offer some assistance.

      There is a bug in the json confit file. I'll fix it and update it today.