awww yiss.

Navigation

Idiot’s Guide to a Raspberry Pi Garage Door Opener

Update 4/22/15: It has become apparent that WebIOPi is not yet compatible with the Raspberry Pi v2. If you are following this tutorial, you must be using the first-generation Pi. The link below for the B+ model is still valid, and this model will still work for this project.

Updated 11/17/2014: I’ve updated the Amazon links to point to the new Raspberry Pi B+ revision. Please note that if you’re going to use this version, you don’t necessarily need the USB wireless adapter listed below since the B+ revision of the Raspberry Pi includes a wired LAN port. Another note is that the B+ revision now uses Micro SD cards rather than the full-size SD card. The guide has also been updated to reflect this.

Recently, I read a blog post (http://freemansgarage.com/blog/?p=587) about configuring a Raspberry Pi to become an internet-connected garage door opener – meaning you can control your garage door from any device with an internet connection. I had never used, or really thought of using a Raspberry Pi for anything at all, or anything related to home automation, but this really piqued my interest. This project could prove useful for things like letting in a repairman or family member to your home when you’re not there, or if you simply lose your dedicated garage door remote or its batteries have died. Or it’s just really cool.

Along with the post I linked above, most tutorials I came across involved making circuits with breadboards or something similar for the magnetic switch sensor portion, but I didn’t have anything like that laying around and to be honest, it seems to over-complicate things. This project can be accomplished with no soldering or breadboards required.

To start with, the build list:

– Raspberry Pi (Updated this link to the B+ model since it is the most readily-available revision)
– Plastic Case for the Pi (This isn’t necessary, but will keep the Raspberry Pi safe. Has a hole to allow jumper wires through)
– 2-Channel Relay (One channel will be used for the door, the other could be for a future use)
– Wireless USB adapter (Raspbian has built-in drivers for this wireless chipset to make things easy)
– Magnetic Switch (This is only necessary if you want to be able to determine if the door is open or closed)
– Wire for the magnetic switch and connecting the Raspberry Pi to your garage door opener (I used extra CAT6 cable I had laying around, any 2-conductor cable ~20-24 gauge should be fine)
– Micro SD Card (You probably have some extras kickin’ around, 4GB or larger recommended, I went with 8GB in case I wanted to add stuff later)
– Female-to-female Jumper Wires
– USB to serial TTL adapter (This is also discussed below. It is optional, but this tutorial assumes you’re using a serial connection)
– MicroUSB Charger (You might have one laying around, at least 1 amp current recommended. Make sure you have a place to plug this in near your garage door opener)
– Wire Nuts (for connecting wires and resistors together, might be able to find them cheaper at a local hardware store)
– 1 10k Ohm resistor (You can get a pack of them from RadioShack for less than 2 bucks)
– 1 1k Ohm resistor (Again, a pack from RadioShack for a dollar and change)

First things first, you’ll need to get an operating system for your Raspberry Pi installed onto an SD card so there will be some type of user interface. Plug your SD card into your PC or USB SD card reader, then go to http://www.raspberrypi.org/downloads and download the image for RASPBPIAN Debian Wheezy (under the OPERATING SYSTEM IMAGES section). You’ll download a ZIP file that’s around 780MB. Once this is done downloading, open the zip file and inside you’ll find a file with a .img extension – extract this file to your PC and remember the location where you extract it. Since Windows doesn’t know how to handle this file natively, you need to download a program to write this image to the SD card. Download Win32 Disk Imager from http://sourceforge.net/projects/win32diskimager/ and install it. Run the program and you’ll get a box that looks like this:

Click on the blue folder icon and browse to the folder where you extracted the .img file previously. Double-click on the .img file in the ‘Select a Disk Image’ dialog and you should end up with a window similar to this:

Make sure you have the correct drive letter of your SD card (or USB SD card reader) selected under the ‘Device’ heading. Once you’ve confirmed the correct device is selected, click ‘Write’ and let the program write the image file to your SD card. Once this process has completed go ahead and safely eject the SD card from Windows and insert the card into the bottom of the Raspberry Pi.

Now, depending on how you want to communicate with the Raspberry Pi, you’ll either need a USB hub to connect a mouse and keyboard to the Raspberry Pi and connect to a TV or monitor with HDMI, or connect to the Raspberry Pi via serial interface. I opted for the serial interface since I already had a USB to serial TTL adapter from another project. My instructions will assume you’re also using the serial method and already have the appropriate drivers installed for the adapter and have a COM port assigned. One thing to note, you should only have to connect the RX and TX cables to the Raspberry Pi since it will be powered via USB connection.

This is the Raspberry Pi PCB and diagram of where the GPIO, VCC, ground, and serial pins are located:

Now you’ll want to connect your USB to serial adapter pins to the UART0 RX and TX pins (8 and 10) and one of the ground connections on the Pi. The RX on the USB to serial adapter goes to TX on the Raspberry Pi and vice versa. You can also go ahead and plug in the wireless USB adapter at this point, but it won’t connect to your wireless network yet since the encryption settings are not configured. Once you have these wires connected you can go ahead and power up the Raspberry Pi. You should see a red power light below the blue 3.5mm connector as well as a green activity light that shows file system read/write activity.

You’ll want to click on the ‘Serial’ radio button and make sure you input the correct COM port that is connected to your Raspberry Pi (COM3, for example). You’ll want to make sure and change the baud rate to 115200 (just type it in the box). Once you’ve done this click ‘Open’. A black window might be all you see, so press ENTER until a login prompt appears. The default username/password is pi/raspberry. You’ll probably get a message saying something about this being the first time you’ve run Raspbian and to run raspi-config to configure some settings – you’ll want to do this now. At your command prompt, enter:

sudo raspi-config

You’ll get a configuration menu – the only thing to bother with right now is enabling SSH connections so you can connect to the Pi via network later on. Go to Advanced Options, then SSH. It’ll ask if you want SSH enabled or disabled, select ENABLED and it’ll update the configuration and kick you back to the command prompt.

The first thing you’ll want to configure is the wireless connection, so you will need to assign an IP address to the Raspberry Pi. To do this some configuration file editing is necessary. The first file you want to edit is /etc/network/interfaces, so at the command prompt, enter the following:

sudo nano /etc/network/interfaces

This brings up the nano text editor with the contents of the /etc/network/interfaces file, like this:

The contents of your file will be different, but you’ll want to edit it to resemble this picture. You can use your regular letters, delete, and arrow keys to make changes to the file. The part where your settings may differ from mine are the address, netmask, and gateway lines. My router is configured for the 192.168.1.xxx subnet, so I decided to assign the address as 192.168.1.10. Your router might be 192.168.0.1, so you could use an address like 192.168.0.10. The netmask will almost always be 255.255.255.0, but you’ll want to confirm the correct value in your router’s settings. The gateway address is the address of your router. Once you have the file edited to the correct settings, press CTRL+X to close the file. It will ask if you want to save the modified buffer, press Y. It will then ask the file name you want to write, just press ENTER. NOTE: If you get a permission denied error when you try to save the file, it’s because you did not have ‘sudo’ in front of your nano /etc/network/interfaces command. You’ll have to close the file without saving changes and at the command prompt, type:

sudo nano /etc/network/interfaces.

Now you need to get the Raspberry Pi connected to your encrypted wireless network. You should be back at the command prompt, so enter the following:

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

You’ll get a window that looks like this:

Again, use your keyboard to navigate the screen and match your file with what I have here. Replace YOURSSIDHERE with your wireless network name (2.4GHz only) and replace YOURPASSHERE with your WPA/WPA2 passphrase. Press CTRL+X to save, Y to confirm, and ENTER for the filename. Now it’s time to reboot the Raspberry Pi and see if it’s reachable via network. To reboot the Pi, at the command prompt type:

sudo reboot

Your Raspberry Pi will reboot and you’ll probably see the booting status in your terminal window. Eventually, you’ll arrive back at the login prompt – go ahead and login (again, the default user/pass is pi/raspberry).

Now you can check if your network settings took effect. To do this, at the command prompt enter:

ifconfig

You’ll see the loopback connection (lo) and your wireless connection (wlan0). In the wlan0 section you should see inet addr, bcast, and mask. As long as this has the information you entered in the /etc/network/interfaces file, you should be set! If you’re still having troubles with WiFi, try consulting this guide on ThePiHut. At the command prompt type:

sudo shutdown -h now

This will gracefully shut down the Raspberry Pi and halt all processes. The red power LED on the Raspberry Pi will still be lit, but the green activity light will stop flashing and you’ll see a shutdown message in the terminal window. Once the activity LED is done flashing, go ahead and unplug the power from the micro USB connector. Remove the serial cable jumpers, plug the micro USB cable back in, and restart PuTTY. This time, when you start PuTTY, leave the SSH radio button selected and type in the IP address that you gave the Pi previously (in my case it was 192.168.1.10). Now when you click ‘Open’ you might get a prompt about accepting the machine’s ID, go ahead and confirm and you should be greeted with the familiar login prompt. The login is the same as before (pi/raspberry).

Phew! It took me a little while to get the wireless working my first go-round, so hopefully my experience sped up the process for you a little.

The next thing to install is WebIOPi. WebIOPi provides a web interface to control the GPIO pins on the Raspberry Pi, and thus, the garage door opener.

You’ll want to make sure you are working in the home directory on the Pi, so at the command prompt enter:

cd /home/pi

This gets you back to your home directory where files can be written as necessary. Now you are going to enter several commands to get WebIOPi installed and configured to run at boot. Bear with me and just enter the commands as followed, one by one, waiting for the previous one to complete (you’ll get a command prompt after each step completes). Ready? Enter:

Once the commands are all completed, you should end up back at the login prompt. At this point, WebIOPi should have installed successfully and already started running. To test this, open your web browser and navigate to http://192.168.1.10:8000 (you’ll want to make sure and use the IP address you assigned instead of mine). You should get an HTTP login prompt, and the default login/pass for WebIOPi is webiopi/raspberry. Is it working? If so, congratulations! If not, post a comment below and I can try to get you up and running.

If it worked for you, it’s time to get busy connecting some wires. Go back to your PuTTY window, login if necessary, and shut down the Raspberry Pi by entering:

sudo shutdown -h now

Once you get the shutdown message and the green activity light stops flashing go ahead and unplug the power from your Raspberry Pi.

Alright, now get your bundle of jumper wires – you’ll need 3 of them, and also break out the 2-channel relay if you haven’t already. Here’s a crude diagram of how you want to connect the wires to your relay:

The connections are as follows: pin 2 (5v) on the Raspberry Pi to VCC on the relay, pin 6 (ground) to GND, and Pin 26 (GPIO 7) to IN1. Once you have this connected, the next step is to make sure you can control the relay with the WebIOPi interface.

Power the Raspberry Pi back on, open your web browser, and navigate to your Raspberry Pi’s IP address with port 8000 (again, mine was http://192.168.1.10:8000). Log in to WebIOPi (user: webiopi pass: raspberry) and click on GPIO Header – you should see a diagram of all the GPIO pins and their status. Find GPIO 7 on the bottom-right and click on the ‘IN’ next to it. Did you hear the relay click and a little LED on the relay illuminate? FREAKIN’ SWEET, RIGHT? Congratulations on making it this far, you’re NEARLY done. If you don’t want to have an open/closed sensor on your garage door, the only thing you really have left is to upload an HTML interace to your Pi and connect the relay to your garage door opener. I’ll go over that in a little bit, but first, I’ll tell you how to connect the sensor.

Getting the magnetic switch connected and working properly was the most time consuming part of this whole setup for me. Mostly because I’m terrible at reading circuit diagrams. My ignorance in reading diagrams resulted in the door status constantly flashing between open and closed, even though the door was indeed closed. The gist of this, from my understanding, is that the GPIO pin on the Raspberry Pi that gets used for an input for the switch floats between a high and low state and we need to prevent that from happening with resistors by ‘grounding’ the pin and making it stay in a reliable state.

I ran some CAT6 cable from the side of my garage door (inside the garage, of course) to the top of my garage door opener. You can kind of see the yellow cable in this picture (click for a larger image):

And this is what the sensor looks like on the left-hand side of the door (click for larger image):

You can see that I have 2 wires connected – one to the COM (common) terminal and one to the NO (normally open) terminal. If you’re using the relay I linked at the beginning of the post, you’ll also want to connect your wires to these two terminals and ignore the NC (normally closed) terminal. I used the blue and white/blue wires from the CAT6 cable, but that doesn’t really matter as long as you use the same pair on both ends.

Below is an extremely crude diagram on how to connect the sensor to your GPIO pins with wire nuts. You’ll have to cut a few jumper wires in half and strip off some of the insulation so you have exposed wire to make your connections. The wire from the COM terminal splits off in two directions – one of the wires goes to the 3.3v pin while the other wire goes to GPIO 18. Make sure to include your resistors otherwise you’ll end up having a floating GPIO status. The N.O wire from the switch just goes to pin 14, which is a ground.

That wasn’t so bad was it? Now the last thing should be connecting the relay to your garage door opener. Most garage door openers should have at least a few screw terminals for buttons or lights, and when two of the terminals are connected electronically it should result in the door opening or closing. I found out which terminals I needed just by touching a wire between them – pretty simple. Here’s a picture of the back of my opener and you’ll see the red and black wires connected to the 2 leftmost terminals:

The red and black wires are going to my relay. The relay also has a normally open and normally closed state, so here’s another picture of where to connect the red and black wires:

I think at this point most if not all of the wiring is complete, the last thing we have left to do is upload an HTML file to provide a GUI for controlling our relay. I’ve made my documents available and here’s how you can get them on your Raspberry Pi:

Fire up PuTTY again, connect to your Raspberry Pi’s IP address, and login. You’ll want to make sure you’re in the home directory, so at the command prompt, type:

cd /home/pi

Then type the following to download the required files

wget https://www.driscocity.com/rpi/garage.html

wget https://www.driscocity.com/rpi/doge-static.png

wget https://www.driscocity.com/rpi/doge-action.png

wget https://www.driscocity.com/rpi/open.png

wget https://www.driscocity.com/rpi/closed.png

Now you need to move these files to the WebIOPi htdocs folder, so use the following commands and make sure to include the ‘sudo’ part or you’ll get a permissions error:

sudo mv garage.html /usr/share/webiopi/htdocs

sudo mv doge-static.png /usr/share/webiopi/htdocs

sudo mv doge-action.png /usr/share/webiopi/htdocs

sudo mv open.png /usr/share/webiopi/htdocs

sudo mv closed.png /usr/share/webiopi/htdocs

Got those all downloaded? Great, let’s check it out! Open a web browser and navigate to http://192.168.1.10:8000/garage.html (note that your IP address might be different depending on your settings). You should see an image like the one at the beginning of this post. Press the gray ‘GARAGE DOOR’ button, does your door open or close? BOOYA. You should see a little animation with the doge meme face and the door status should show whether the door is open or closed.

Here’s a video of what SHOULD happen:

Sorry for the focus problems, but you get the idea. This is what my whole assembly looks like:

It’s a mess of wires currently, but it’s functional. Some day I’ll tidy it up.

If you want to be able to access your WebIOPi page from outside your local LAN, you’ll need to know your external IP address and do some port forwarding. I’ll explain this in another article.

Hopefully this write up helped you get your Raspberry Pi garage door opener up and running. I wrote this post over a period of a few days, so I’m sure there are some breaks or gaps in the instructions. If something seems confusing, please feel free to comment below and I’ll try to help you out.

If you found this howto helpful, I would certainly appreciate any donations via Bitcoin or Litecoin. Here are my addresses:

219 Comments

Hello
I could use some help. I was good up till the end. Switch works and I can trigger the relay, but on the webpage all I get is a Grey screen with “Door Status” on the top, no buttons or doge meme. I can see all the files moved to the folder/usr/share/webiopi/htdocs. Would really like to get this working properly.
Greatly appreciated for your time and effort.

The Raspberry Pi is without a doubt sheitomng truly innovative. I have heard about these micro-computers used in several projects and experiments. It may not be the specs but its the size and compact components that is mind blowing. I believe that will not only continue to capture everyday customers but people who want to take this to the next stage by tinkering with it to perform other tasks. Just as you mentioned with Google’s Project Loon. This will be a stepping stone for many other things soon to come.

HelloI copied your files into my Apache 2 dir, /var/www/html/CPUStatusI atpmetted to follow your instructions with visudo and addedwww-data ALL=(ALL) NOPASSWD: ALLat the bottom.When i browse to index.php I see a background image but nothing else.There is probably some permission or something I have missed. Can you point me in the right direction?The page looks really nifty.John

Thanks for pointing that out – forgot I had run the javascript files through a minimizer to reduce page size. I’ve updated the original garage.html file in the howto to point to the original webiopi.js file.

I use FileZilla FTP Client to connect via SFTP to the Pi. You use the same SSH username and password when connecting. You’d navigate to /usr/share/webiopi/htdocs in FileZilla, download the garage.html file to your computer, edit it, and then upload it again. If you get a permission denied when trying to overwrite the file, you’ll probably want to log into the pi via root instead (you’ll need to set the password first, let me know if you need help with that).

Great! I was able to pull the file from my Pi using Filezilla. I’m just playing around with it and trying to understand everything that’s going on. My first project with a Pi and has really been a fun learning experience. I haven’t tried putting it back in yet, but will let you know if I run into problems. I probably won’t even put a new file back in though.

One quick question, is there any issue with a having the Pi running in a garage when it’s a 100 degrees outside or is it able to handle a hot garage?

I think you could probably accomplish what you’re looking for, but you’d probably have to write some python scripts and integrate that with WebIOPi (or maybe some other software). Unfortunately, this is not something I’ve tried to tackle so I’m honestly not sure what direction to point you.

I forgot to answer your first question. Yes my Garage door “App” is working now. I have added to the html for displaying a Cam. That all works fine. I also change the port to my GPIO pin for the magnet sensor.

rebooting raspberry, and relay not work, i need to go to change the header gpio- gpio7 change in> out, click gpio7 , came back running relay , but does not work and restart rasberry. What I’m doing wrong?

hello, restarted the raspberry, the relay does not work, restart the Rasberry, return to change the GPIO GPIO header in 7 out hit GPIO, the program works. What I’m doing wrong? or where a mistake? Can you help?

Thank you for the excellent and clear instructions. I was able to set this up with a few modifications; would like to add one more feature. I have a second relay on pin 18 gpio 24. Looking for assistance on adding html code to place a button at the bottom of the current interface (beneath the yes no buttons) to show the relay status and activate the relay to turn the light on/off? Any help is appreciated.

I’m not sure if you’d be able to determine the relay status from webiopi, since you’re just sending a signal to it for the toggle action. I could be wrong, of course, but I can’t think of a way to do it.

Great tutorial. Everything worked. Only thing I didn’t use was the USB to serial TTL adapter ( I don’t know why you used it).
The only changes i am going to make is to replace dog picture with the live feed from Motion since the PI was in the garage as a security camera. And i want to put a Crack button to have the door open one foot in the spring for fresh air.

Thanks for the tutorial – I just finished installing my garage door opener today! I put the Pi and relay in a small weather-resistant case, which they fit in with only a bit of modification required. Like the poster above, I didn’t use the TTL adapter, but had no difficulties downloading and configuring software using a wireless network connection and PuTTY. I also configured my router to reserve the IP of my Pi rather than mess with the Pi’s network config to get a static IP. BTW, the dog pic is cute, but how can I modify the HTML file to use another pic, if I should choose to do so?

If you want to change the dog face, there are a few places I reference it. I’m sorry if this explanation is overly wordy, but I want to explain the image process. The first place you’ll want to look is at line 104 of the garage.html file. You’ll see this line:

background: #808080 url(‘doge-static.png’) no-repeat center bottom;

This line is for the dog face before the button is pressed. You could just change the doge-static.png to whatever image you want, just make sure the filename is inside the single parenthesis. Also, if the image is not in the same folder as your html file, you’ll need to reference the correct path. Alternatively, if you didn’t want a picture at all, just delete everything after the #808080 up to the semicolon.

When the button is pressed and you select ‘Yes’ to the open/close confirmation, there is a second image file that loads in place of the above picture. This is at line 44, which reads:

I have 2 garage doors. I’m sure I can hook one relay to one door and the other to door number 2. My question is: What would it take to have two buttons on the page and two status notations on the page?

It shouldn’t take much more than some extra HTML and JavaScript to handle the added GPIO pins. I actually made a demo page for a friend of mine that has 2 garage doors:

If you told me what GPIO pins you would be using for the relay and magnetic switch I could modify the HTML file and upload it, or you can click here to download (right-click and save as) tinker with the file that I used.

I have the same question and I have the relay connected to GPIO 23 and 24. I dont have the magnet switch yet, but hope to get them soon. Is it possible for you to write the code and html for 2 garage door for me please? Also is it possible to connect the two switches without the resistors and what GPIO pins can i use?

Hi Chris. Thank you for the great tutorial and inspiration. Followed your tutorial and enhanced the code slightly. When i wanted to provide a reference, found that you already had something for two doors 😉 But anyway, if someone will find it useful, please feel free to use it https://github.com/pioneer903/garage/

Hi, I liked your blog a lot, it’s inspired me to buy a relay and connect it to my Pi, I got the satisfying click and the LED on the modlue so thought I was well on my way.
But I came across some confusion on the GPIO circuitry about which pins can be used and dug a bit deeper. It seems that the 2nd, smaller 3 pin connector on the relay board has a jumper which connects the VCC on the 5v relay activation circuit to the VCC on logic circuit. If I’ve understood correctly it means that the GPIO pins are getting fed 5v and not 3.3v.
Most other examples of using these relay boards have connections like yours, so I guess there’s been no damage, but wondered if my understanding is correct?

Hello Chris!
Thanks for this project, i love it!
I have a problem, i had follow every step of this guide but i don’t know why my relay didn’t work.
With the webiopi gpio-header when i press the gpio 7 in out mode it works perfectly!
What’s wrong? could you help me please?
I have a raspbian with last webiopi, i tried to change gpio pins in garage.html for try but nothing..
thanks
Pierantonio

Chris,
Thank you for taking the time to write this guide. I was able to get everything setup without too many issues. I added a second sensor to detect the status of a back door in the garage and was able to figure out how to add a status button to the HTML, but am stuck on the CSS. My second button works, but is partially hidden behind the main Garage Door button. I need to move the Garage Door button and confirmation prompt down to allow space for the new button, but can’t figure out the CSS. Any help or guidance on this would be appreciated.

just a couple of questions, I am trying to move all the buttons on the web page so they are all aligned along the top of the page to look something like the following ( with are you sure in smaller font) and yes no still hidden until OPEN / ClOSE pressed

DOOR STATUS OPEN / ClOSE YES are you sure NO

I have had partial success but cannot get them all aligned at the top of the page, is there something you could do to assist or point me in the right direction ? I have played with all the css stuff at the bottom of the code and can’t get it aligned, is it something webiopi is doing ?

CloudFlare is a CDN my host uses to help with speed and security of the site. If you’re trying to view https://www.driscocity.com/rpi/garage.html directly in your web browser you’ll probably get some CloudFlare code in there, but if you use wget from the command line to download the file then the CloudFlare code should not show up.

thank you for the tutorial very neat I’ve got everything connected and when I access the website at 8000 all of the blocks are grey with no in and out on them so I’m not able to control the GPIO circuits. any help would be appreciated. when I use your wiring diagram the LED lights on the two channel relay do not come on but when I use another persons wiring diagram with 4 wires the LED lights come on but I still have no GPIO blocks with any text in them

Hi, great tut! Unfortunately I’ve the same problem as Pierantonio. I checked every step twice and did the whole tutorial 5 times hoping I did something wrong and tried both versions Webiopi 0.7.0 and 0.7.1 without success. Could you please help me out?

I added some features. I wrote a python script that watches the sensor. When it detects the door is open, it emails you after 10 minutes and after 50 minutes of being open. It also closes the door automatically after 60 minutes. (You could, of course implement either feature separately, and tweak the specifics.) I’d be happy to share the script if you let me know how best to post it.

One thing I’m trying to add is a feature where the RPi reads the status of the beam sensor at the bottom of the door (the one that stops the door from closing when something’s in the way). I’d then re-write the script above to close the door after 60 minutes of no activity crossing the door — that way if I want the door open for a long time because I’m working in the yard, it won’t close on me. I tried to set that up, but I got some errors. I connected one terminal of the sensor to a new GPIO pin, and the other to ground (shared with the relay). Do you (or does anyone who reads your site) have any suggestions?

Have you got Darin’s reply on sharing the Python script to auto close the garage / sending txt after certain amount of time?

I followed your excellent tutorial and got the Pi3 and switch to work with the relay. Also tried the switch at my desk by playing with them. I can get the garage door web page to change status when pulling the switch receiver apart or make them close. Next step is physically mount them into the garage.

I would very much appreciate it if you could share your script for sending emails, etc (nmacle01 AT gmail DOT com).

I, too, have tried to read the status of the IR Beam Sensor to be able to determine if it’s safe to close the door remotely or programmatically after a set amount of time. If you still have those two wires connected to your Pi, I would recommend removing them. I can only assume it’s the same on most garage door openers (GDO), but those IR Beam sensors are powered (5V-12V) so you certainly don’t want 5V (or maybe even 12V, depending on your GDO model) running into your GPIO Input Pin that’s only rated for 3.3V!

On my Genie Excelerator GDO, pins 3 and 4 send out 12V signal to the Safe-T-Beam Sensors. When the receiver detects the beam (no obstructions) it somehow modulates the 12V signal which the GDO picks up and knows there’s no obstruction, allowing the door to close. And when the receiver doesn’t see the IR beam (there’s an obstruction) there’s no modulation in the signal and the GDO knows the signal is the same as what it’s outputting, so there must be an obstruction, and it doesn’t allow the door to close. I tried opening the beam transmitter and receiver to see if I could “piggy-back” on some internal switch or relay or something, but had no luck. If you, or anyone else, figures it out, please let me know!! 🙂 This video explains how this works: https://www.youtube.com/watch?v=GbmufXgpl14

If you’re interested in any scripts or maybe my wiring diagram I’d be happy to share…

Chris
Many thanks for the tutorial.
My first project with a raspberry pi.
It works a treat and I am well chuffed.
I would like an extra sensor to check on whether the back door to the garage is open or shut.
But I have not got a clue when it comes to editing html.
I did download Kompozer to see if I could have a go at adding another sensor.
But the preview shows everything all over the place, and not how it looks for real.
So, I am unable to get any further.
A bit of a nerve I know but I am wondering whether Josh might be willing to share his html for an extra sensor.
Regards Derek

Hi Chris,
Great tutorial. I know nothing about programming and I don’t qualify as an idiot. I found your tutorial and am trying to follow your steps. I have the same problem with the WebIOPi-0.7.0.tar.gz. It downloads without any problem but your try to unzip, it gives the following error.

gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error is not recoverable: exiting now

I’m having trouble with the relays. With only three wires, it’s pretty simple! But I cannot get the relay to trigger. I have reviewed all of the connections and updated the Java, but it still does not trigger the relay. I am looking for some advice on where to start troubleshooting….

Wonderful tutorial. Appreciate your initiative. Easy to follow for someone with very little computer or software background. But I have run into a problem with the WebIOPi. The GPIO header is greyed out. I don’t see any IN or OUT. Maybe the problem could be because I am using the Pi 2 (new model). Can you correct me if I am wrong? Will this tutorial work for the new version as well? TIA.

Hi Chris, I have it all up and running, the Pi is installed in the house, the relay is wired to the door button by the back door (snaked through the wall so it is not visible), and the magnet sensor is tucked away at the top of the door (again, all wires are inside walls) and it all works great!

Thanks a bunch for the parts list and the tutorial!

I would like to have it send an e-mail when the status changes, do you have any advise or instructions on this?
Thanks,
Jason

Apologize for the delayed response. Changing to GPIO2 didn’t help either. I am actually just trying to check if the relay works using a LED. The red light on the relay lights up and I hear a click but the LED does not light up. Not sure if I am doing something wrong with the connections or if I have a bad relay. Thanks for help anyway.

I have two garage doors and I have the relay connected to GPIO 23 and 24. I dont have the magnet switch yet, but hope to get them soon. Is it possible for you to write the code and html for 2 garage door for me please? Also is it possible to connect the two switches without the resistors and what GPIO pins can i use?

Im stuck at the part where you set up the webiopi and connect the wires to the relay… the GPIO status isnt showing on the website… not even sure if thats the right terminology but the outer boxes where it should say IN or OUT are just blank… also the buttons with the numbers 1-26 dont toggle when i click them, they just become a lighter color while i click them….. im a total noob btw if it wasnt already obvious

Hi ! Thank you for this guide, but I’m stuck at the last step. I see the gpio headers on m browser, I can turn 26 in into 26 out and then when I press the number 26 itself my relay clicks, no problem with that. But as soon as I try clicking the “garage door” button using the garage.html, it just turns the 26 out into 26 in again and then nothing happens, no click on the relay.
Is there something I did wrong ? Thank you for any kind of help.

Thanks Bucko/Todd for confirming. I used Bogdan’s instructions to setup the webiopi. I have not connected the pi to the garage door opener but want to test it with an LED. I have connected an LED to the relay switch. When I click on the button, I see a red light on the relay and hear click but the LED does not light up? Am I doing something wrong?

Sounds like you’ve gotten webiopi working, especially if you can hear the relay switching and the relay’s LED is illuminating. Are you sure you’ve connected the LED properly (pulled up through a resistor to 5V with the relay contacts closing to GND on the bottom of the LED)?

Thanks Todd. I think that was the problem. I guess my connection to the LED was not right as you suggest. I connected directly to the garage door opener and it worked. All this while I thought the relay was not working. Thanks a lot.

Hey thanks a LOT for this, this is something that I have been doing for a while now, just didn’t know how.I got it all configured, and working with ease, except WIFI, I have an open network that is locked down to MAC addresses, and I can’t for the life of me, get it to connect. I am just going to use a CAT5 and run it out there.

Unless you have any ideas.

I haven’t got it connected to the door yet, but everything works with the multimeter,and online (using dyndns, and port forwarding)

Ok, need some help got it all up and running, and connected to my door, however I guess I bought a normally closed switch, when my door is opens closed, when it closed it says it’s open, is there anyway I can fix this within the HTML or do I need to buy a new switch.

Chris,
Thanks for the excellent tutorial. I am using the 2 door garage html file you have provided and implemented it on a raspberry pi2. Everything is working fine however I needed some help from you on html coding. I want to put a camera feed below all the buttons therefore I wanted to move the yes/no confirmation buttons on the top where the door status buttons are located. Basically, door status buttons should show normally on the top but when someone clicks on the left or right door buttons the door status buttons should disappear and replaced by the yes/no buttons. When someone makes a selection of either the yes/no should disappear and replaced back with the door status buttons. Reason I want to do is to have space for the camera feed without scrolling up or down on my phone. I would really appreciate your help in this regard. Thanks

Thanks for the great info, I have rigged up two garages based on this, but had a question as to how the actual resisters were determined. I also had a question about the relay.

For example, GPIO17 for the magetic switch can supply 0v or 3.3V. You also have the hook up to the 3.3V power supply. How did you know to use those specific resisters for both of them, and how does GPIO17 interpet the data from the magentic switch?

Also, the relay has its own 5v power supply, I get that, the GPIO pin to power it just throws power to the relay and nothing else?

Went to Radio Shack to pick up some resistors and they wanted to know how many watts? I’m new to this and don’t have a clue what to use. Can you help? I have everything wired just not to the opener at this point. All looks good so far. Looking forward to getting it all up and running. Great How-To.

Just a quick question. Everytime i want to trigger this program, I get asked for the webiopi username and password. Fine for me, but I would like to be able to set this up in the phones of various family members without having to get them to remember yet another login. Is there any way to bypass this?

I have tried to do the same but I don’t think there’s a way without disabling the password lock on webio. You can change the login credentials to easy one(ex. User:a Pass:a).
Let me know if you find a way.

I was awakened at 2:08am yesterday morning to my cell phone receiving a txt that Garage Door had just closed. I looked outside in time to see the local police department pulling out of the driveway. After reviewing the cameras on the front yard, driveway, and inside the garage, I saw the office pull up, get out, walk into the garage, hit the button and then run and jump over the safety beam.

I was very pleased with all of this, but it got me thinking… what if it wasn’t the office that walked into the garage?

I immediately found a use for the second relay on the two relay board that was attached to my PI. There is now an LED peaking through the crown molding in my bedroom above the door. If the LED is on, the door is open. If the LED is off, the door is closed.

Now when my son forgets to close the door, and I forget to check the door at bedtime, I won’t be able to sleep if that LED is on.

I first looked at Twilio, but couldn’t justify the effort or the expense when Verizon Wireless (My carrier) allows you to send email messages to YourCellPhoneNumber@vtext.com and they push them to your phone via txt message. I usually have the txt pop up on my phone before the garage door is all the way up, so that means I get the txt in about 7 seconds.

I added e-mail functionality (with a lot of help from Toshi Bass in the webiopi google group) that just sends an e-mail to my e-mail address and both of our cellphones.

The index.html goes in your webroot. My web root for my webiopi stuff is: /usr/share/webiopi/htdocs/
and the doorstatus.py goes in your user folder, if you left it at default, it will go here: /home/pi/

Then, make sure you adjust the /etc/webiopi/config file and add a line like this to the [SCRIPTS] section:
door_script = /home/pi/doorstatus.py

I have followed your instructions to set up the text message option but my server doesn’t work after i set it up. It says page not available. I have edited the doorstatus.py to my preferences and it still doesn’t work. Without the doorstatus.py, it works fine. Also i am using the 2door.html file. Can you help me please?

This has been one Great project – I’ve made it to the end and all is working great except (just had to be one problem) when the door is open the app says “closed” and when the door is closed it says “open”. I guess I could live with this but it is such a great project I hate to leave it at that stage. I’m sure I’ve crossed a wire or placed a file in the wrong dir.. btw I’ve tried powering off the pi and opening the door etc and this didn’t help. I also disengaged the switch at the garage door and the relay…The software is smarter than I am… Out of options at this point. A little hint would be greatly appreciated…

Anyone have issues with the pi dropping wifi? My pi is in the garage and wifi goes to sleep after some time of inactivity. I searched around for solutions but none helped. just wondering if any one here had the same problem and if they have a fix.

There isnt a problem with Wifi going into a sleep mode. BUT if I lose connection for any reason I have to restart the pi to connect again. I would try moving your wireless access point or setting up a wireless access point closer to your garage.

Hi Chris, thanks for your reply. Wireless signal does not seem to the issue in my case. I even placed the pi next to the router. It always seems to lose connection overnight. I dont see the blue light blinking in the morning.

Could be one of two things that I know of. The first which I have run into several times is that the power adapter isnt putting out enough power to run everything. I tried using a 1 amp power adapter and the pi would start, but as soon as I hooked anything to it it would freeze or restart. I use 1.5 amp or 2.0 amp power adapters now. You can see what the amperage rating is on the adapter itself.

FYI 500ma=0.5 amps
700ma=0.7 amps and so on.

The other option is possibly a defect in your card, this is a possibility, but I would check your adapter first.

I did this project almost successfully. Only thing that doesn’t work is when the garage is closed, the status on the page flashes b/w closed/open/closed. When the garage is open, it stays OPEN steady. Any insight someone can provide to me to fix this would be greatly appreciated.

I’m no expert, but it seems that you didn’t ground the pin and that’s why it “floats”. When it’s OPEN, you have the 3.3V running so the ‘HIGH’ state does not fluctuate. I suggest you to go back to the image of the connection of the magnetic sensor (https://driscocity.com/wp-content/uploads/2014/05/sensorwiring.jpg) and recheck your circuit.

Hey, great post! I was struggling to get the reading on the GPIO pins. I thought there was something on the code that was not working. You know what it was? I skipped the step of installing WebIOPi because I already had it installed. After 1 day of tweeking the code I noticed that the version used here was 0.7 and I had installed the 0.5 version. I updated WebIOPI and… voilà!!! Everything worked like a charm!

In the garage.html file after the “title” statement add the following line to specify the icon that is to be used when the webpage is installed to the homescreen as an app, and surround the statement with less-than and greater-than characters commonly seen in HTML files:

link rel=”icon” sizes=”192×192″ href=”/doge-static.png”

If we are using Chrome then the homescreen app will appear as regular Chrome bookmark. Add the following line afterward in the garage.html file to make this a homescreen installed app instead, and again and surround this statement with less-than and greater-than characters:

The information I shared was primarily for Android cell phones with the Chrome browser. How about Apple cell phones with the Safari browser? It can be done too. But first make a copy of the garage.html file.

Add the following line in the garage.html file to make this a homescreen installed app with a nice icon instead of a Safari bookmark. Surround these statements with less-than and greater-than characters:

A great project!
Everything works for me but I am using a 2 wire reed switch so I am confused how to connect the 2 wires from the switch to my raspberry pi. I am guessing I would need to change the html code as well if the GPIO pins are changed. Can somebody please help.

The sensor works for me. Everything is wired up as per the instructions and I can hear the relay click but my garage door won’t open at all. I never had this problem, it is only after connecting the reed switch that I have encountered this problem. https://www.dropbox.com/s/cxw5ajz1iuqoskl/GarageDoorRelayControl.png – this link shows the wires going from the terminals in my garage opener to the relay’s NO and Common ports.

Any ideas what I am doing wrong here? Any help is greatly appreciated.

Thanks for the tutorial. Got everything set up within an hour or two. Doesn’t appear your still responding to these comments it I’ll give it a shot anyway. I’ve noticed that when my garage door is operating, the relay is clicking non stop — on/off repeatedly until the door stops. Is this normal? Will it eventually burn out the relay? Thanks.

Hi Chris,
Thanks for the excellent article. I had two issues that took a while to solve… hopefully my experience can help others. Firstly my wifi worked only occasionally – I replaced the wifi USB dongle that I had bought with the Pi with an old one I had lying around and that fixed that problem. Secondly, I found I could ping to an IP address but not to a website – I added this to the ‘interfaces’ file and that problem was solved:
dns-nameservers 192.168.0.1 8.8.8.8
(this sets the dns to Google’s dns)

The issue that I had was seeing gray boxes where the pin numbers should’ve been when viewing WebIOPi’s Web interface. This mod fixed that problem, but you’ll still see only 26 pins. That was enough for me, though. Mod those two files, run ‘setup.sh’ again, use only the first 26 pins, and you should be good to go.

Thanks for the post, I used parts of it to build my electric gate opener (bit different). Now one question: can we add automatic authentication for WEBIOPI? I don’t wanna submit the UN and PW each time I open the website in my RPi….Any ideas?

I am having a time of it here. I have used the Dual door script for several weeks. I wanted to add some temp sensors. I cannot get them to work. I setup a new Pi sd card with Raspi-Wheezy and installed WebioPi 0.7.1 and got the temp senso to work. Great! I copied all the garagedoor files from the working system and put them in the new system and all I get is the buttons in grey and they do not work. They don’t react. My original working configuration I changed the HTdocs location in the webiopi config file. Does java need to be installed? The OPen/closed buttons are grey without any text and the open buttons overlap the status buttons. What have I done or not done?
Thanks

Hello. I followed the guide and most of comments, but am having an issue with my pi1B. I changed the GPIOs to 1 and 2 as I have them wired, but the buttons do nothing after asking to confirm? I’d also like to remove the status (I did in the garage.html by //’ing the lines), as I am not using those GPIOs for this project and possibly naively believe that is slowing down loading of the interface. Also if I haven’t already overdone my welcome, I would like to add USB webcam streaming to the page. 🙂 I appreciate any help you can offer.

Edit: my webcam does work, I tested with fswebcam. Just need a way to “stream” to the web interface. Still madly googling how to fix my switches not working. Maybe this version of webiopi was not for the pi1? I can ” gpio write 2 1″ ” gpio write 2 0″ to turn the relay light on and off…?

Ok. Got the relay working- the pinout map that I had doen’t match webiopi- so I switched to GPIOs 7 and 8 (like your original two door shows) and tested- worked! As a note for anyone who has this same issue- try the GPIOs at the bottom on the outside edge of the PiB+

@BJ Massey, I like your like to your files. I just have a few questions if you are still around. I can run the camera with the terminal “raspivid”. I just do not know if I have all the right stuff install to get it from that code to the web page “garage.html”. I see in your “script_min.js” file you call a PHP page. is the just a internal temp page?

@Chris Driscoll
Thanks for the write up. I have all your code working just fine. Over a year running.

I just wanted to post here as a big ‘Thank You’ for putting this guide up. I used this guide liberally for the hardware setup. I did end up just writing my own web interface (since I’m using the Pi 2), and a Python script, but your guide was excellent. Thanks again! I learned a ton working on this.

I have Pi 1 and just sourcing the parts, I notice raspbian debian wheezy is no longer available to download on their site, would RASPBIAN JESSIE work? If not then can somebody upload the image file so I can download it. Thanks

Perfect not sure why I couldn’t find it. Just ordering the stuff now and we shall see if I can make this work. Any recomendation on a usb camera? Would any of them work and is there a guide I can follow. BTW nice guide.

Not sure about the USB camera. You might have to be careful about USB power draw from the Pi, making sure to have a beefy enough power adapter. There is a specific camera module for the Raspberry Pi, which might be a good option. I believe it attaches to the top of the Pi’s PCB via ribbon cable.

Completed the project thanks to Chris for the guide. Just one little issue when I leave the stock wall mount garage remote in as well and when pressing the garage door button through the web interface the relay clicks all the time but sometimes the garage door won’t open. When I remove the stock garage door remote wire from the garage door system everything works perfect. I am assuming when both connected the signal from the relay switch is traveling to the stock garage door opener and not to the garage door system as both wires are connected to the same terminal connectors on the garage system. Anybody had this issue and if so what did they do to fix it, I have a craftsman die hard garage door opener.

I have a B+ pi and I can’t seem to get the WebIOPi interface to work, the buttons are greyed out there’s no “IN” or “OUT”, and the clicking the empty grey boxes does nothing. I’ve been trying to get it to work for the past 4 days but it’s harding finding help everyone seems to be trying to get it to work on the Pi2, but no-one seems to be using a Pi1B+. Any help is appreciated.

This is my first time doing anything with a raspberry pi, so I appreciate this site. I was able to get the garage door to open/close by viewing the pins on my phone, but I can’t get the “dog screen” interface to work, so as a result, I don’t have a way to see the door status. Is there a way I can see my sensor’s status without the “dog screen?”

I have a new chamberlain HD210 model that does not have a dry contact type wall button – confirmed by their reps. When I short the two wall wires the GDO does not respond but my previous craftsman used to. I had tried to install a Sonoff WiFi switch, but due to that reason it cannot work the GDO either. Basically no relays can get the GDO to respond and I my options are directed to their branded internet gateway. I know there are DIYers who have implemented self solutions with this types of wet contacts but I haven’t found one yet, I am at the end of my wits. My question first is, is there a way to implement this or a similar solution with a non dry contact type GDO?

Just got this working, first with a Pi 3 model B, then with a Pi Zero. I’m using a 4 channel relay to operate 2 doors using the 2door.html file. I’m trying to add buttons for the lights using the extra relays. I’m using GPIO 7 and 8 for the doors, 17 and 18 for the sensors (haven’t installed these yet) and I would like to use GPIO 9 and 11 for the lights ( I have them wired to the push button on my wall mounted door controller, so would use the same .5 second trigger). I’m not very good with php, so having trouble getting my light relays to work. Any chance you could add right and left light buttons to your 2door file? The tutorial was great and easy to follow. The Pi 3 required the fix by konglingboy that was referenced here. The Pi zero did not need the fix. Thanks for the great tutorial, and the extra help in the comments has been extremely helpful as well!

If you are unable to ping the pi or ssh into the pi and you are sure the IP is correct then two things, the pi lost its routes, if you do a sudo route -n, that should display the routes, if its empty then that is your issue.

Connect your pi to your TV or if you have a usb to serial as Chris stated in the guide to determine if the interface is up by typing ifconfig. If you are using wireless then it should display wlan0 and then the IP address, if you do not see a wlan0 with an IP then something is wrong with the configuration of your wireless SSID or password. Once in the pi try to ping google.com, if it response then that means the issue is on your router and not the pi.

Second issue as stated, log into your router and ensure any settings that displays AP Isloated and WMM APSD is disabled, you will find this setting in the wireless section on the router. Once disabled you should be able to connect to your pi via ssh and ping it, note a reboot of the pi may be required after the change. Good Luck

I did this for myself and it works great however did this also for my brother and once the relay switch is connected to the garage door his car remotes for the garage don’t work at a far distance anymore. You will need to be right up to the door for them to work. I thought it was the wifi dongle but it’s not as soon as I remove the relay wires going to the garage door the remotes work perfectly. Any way I can fix the interference?

Thanks for this thorough guide! Installed without issue today. Created my own images and named to doge-static.png and doge-action.png and overwrote the originals rather than modify the code. Has anyone added a way to run a loop and then auto-close the door if it has been left open after a specified period of time? Bonus points if there is a “hold open” button option that would not run that loop if desired.

Thanks for the tutorial. I’m familiar with the software side of things, but new to wiring. You mentioned cutting a jumper in half and stripping the insulation to connect it to the GPIO pin. How are you connecting that to the blue and blue/white ethernet cables? (per image 7, where you show the magnet sensor connecting to the Pi). For the connection to pin 14, and from each resistor to the Pi, are you tying the ethernet wire to a jumper cable using a wire nut? Thanks!

Thanks for a great write up Chris, perfect for the novice to get the very sought after garage opener working. My B+ is now up and running, such a buzz, but it took some head scratching, and the issues I was having seemed to be shared with many of the previous posts.

I am perplexed as to how many readers were able to get the orginial garage.html to work. With these three small tweaks to garage.html, it worked like a breeze. Basically, my relay was not toggling (I knew it was working from the WEBIOPI header page). First the PIN 7 had to be declared as an “out”, then the it was toggled by the digitalWrite funtion and not the setFunction.

1) setFunction tells the Rpi which pins are outputs or inputs. As pin 7 is an output controlling the relay, it should be “out”.

Thanks Chris. This is great stuff. I got it to work great for a 2 garage doors. Got it to log open and close time and email me if door is left open for more than 5 mins and more than 5 hours. Also, if it alerted me, it will also alert me when it is closed. Also show the last 10 lines of the log on the page.

Modified garage2.html to remove the dog (Sorry dog). Show log when page is loaded. log is read from file created by myscript.py

Created myscript.py which monitor the garage status and log open and close time to a file. Also send alert when door is left open too long.

Created l_logger.sh which log open and close time to l_garage.log.
Created r_logger.sh which log open and close time to r_garage.log
Created mail.py which send email when door is left open too long.

Thanks Chris for the great write up instructions.
Hello Jimmy Chan-ying,
I am a newbie and I don’t know much about unix. I wonder if you could guide me how to modify the config file to adapt with your created myscript.py (in details if it is possible). I also want to have logs of open/close and alerts to be sent via email.
Thanking you in advance

Hello Jimmy,
I managed to get everything working at least via testing. I haven’t physically installed it yet.
Can I have alerts send to both email and text (email to SMS)? I tried to add email address and email to SMS address to “to address and cc address), but it looks like the “cc address” is not working at all. Thanks
Brian

I will follow the instructions to see how it goes. Thanks a lot.
I have another problem to copy file (e.g.garage2.html) over htdocs folder using filezilla. I keep getting permission denied??? Any idea?

I would test the garage door by using a wire to connect the cable where the off or on switch is. The relay just simply allow a connection to go thru like a regular switch. So, if your switch is like a normal switch, it should work. You probably will need a relay with 2 switches. One for off and one for on. If the door close/open by connecting the wires, then it will work. Wonder what will happen if you push both buttons.

Actually got it working just fine today for closing the door. Took some doing because WebIOPi is no longer maintained and doesn’t work on the latest Raspbian software (Stretch). It’ll work on the Jessie versions but with a little tweaking, have to use version 0.7.1 and a couple other little things I’m forgetting.

But anyway, it closes just fine. I thought about taking the two-door version(s) a couple people posted earlier and use it as an open and close, since I have two relays, but ultimately I needed to set it up so I can close the door remotely if someone forgets to at the end of the day. And it’s working fine for that.

And yes, I know the safety concerns behind closing a door remotely. I’ve got one of our security cameras near the door as well, which I can monitor and make sure everything is safe.

Hi Chris,
I have the latest rasbian and 7.1 version of weboipi, and im a newbie to rasbian, just as an DIY i bought everything to make a garage opener via raspberry pi, after installing webiopi as per your instructions when i try and open the web page using IPAddress:8000, i do get the authentication prompt wherein i provide the username and password but as soon as i hit enter, i have a blank white webpage nothing shows up there… am i missing something here.

You can’t use the latest Rasbian, it won’t work right with webiopi. It seems WebIOPi isn’t maintained any more. But you can get it to work with Rasbian Jessie (NOT Stretch). You do have to use WebIOPi 0.7.1

I did find some issues with the webiopi code after upgrading to latest Raspian. The loop section in the back end script did not loop. I changed the code so that the loop runs in a infinite loop by itself. I got that problem after adding a PI cam to the set-up and get it to take picture whenever the door is open. Also added a take picture button to show the current view.

Hi,
I am using this garage door opener for a while, but i would like to use it now with my google home via FTTT. I have been creating a page with automatically triggers the relay for 1 sec when loading the page (without needing to click on something) and then configured everything in FTTT. When i access the page on my computer, it works, but it doesn’t on the google home.