Instructables
loading
loading
Picture of Raspberry Pi Garage Door Opener
breadboard.jpg
psu.jpg
relay.jpg
wifi.jpg
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.

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.




 
Remove these adsRemove these ads by Signing Up
1-40 of 105Next »
Hey, I made it too! Thanks for the instructions. I have one issue. I noticed after a few minutes of stand by and I try to return to the page, it times out. I'm wondering if something is going into stand by or something else may be wrong. It takes me a couple tries before I can get back on. Any thoughts?
One thing that just occurred to me is I had it booting to the GUI. Seems to be doing good now after changing it.
The wireless adapter was going on stand by and the following fixed it. BTW, my adapter is a EDIMAX EW-7811Un

Create the new file
$ sudo nano /etc/modprob.d/8192cu.conf

Add the following
options 8192cu rtw_power_mgnt=0

Then
Reboot


Looks like it's working
Correction: /etc/modprobe.d
jbarrychristian made it!12 days ago

I just finished the garage door opener portion last night. Thanks for a well done instructable! Today, I am adding motioneye to use the camera as a way to see if the door is open or not. Still working on that last part.

IMG_0135.JPG
jc956612 days ago

Would this interfere with a multi-button Wall Panel where you can not only open and close the garage door, but also turn on light, or place your unit in lock mode? If i had a single button opener on my wall this would be straight forward. Please advise if you have any more insights here. thanks and great job! this is pretty darn cool.

MathewS215 days ago

How would you create a password to protect the website?

MathewS216 days ago

Do you atttach new wires from the terminals on the garage motor to the pi or do you use the ones coming from the opener on the wall?

MathewS216 days ago

Which wires do you attach to the relay, the ones on the garage door motor or the opener on the wall?Also, do you need more wires to connect the pi to the garage door motor again since you are going between the connection of the door opener on the wall to the motor?

Has anyone written a .php and code for the ability to control both relays? As in dual garage buttons?

I also would like to have this possibility. The .php and java script are written in comments somewhere below. The last and only problem I have is changing the start up script to initialize the additional pins. I was working on that four hours with no luck. I have two buttons on my web site and both working only on first relay.

Can anyone post changed script to work with second relay?

Are you using your buttons to execute a python script IE: Garageleft.py and Garageright.py?

I am using only one script which starts automatically on start up. I believe one script is enough. I just didn't changed as I should to work with second relay and I have no idea how to do it.

Thanear Thanear23 days ago

I just found out that I've done mistake in .php. Now everything works fine and thanks to comments below adding new relays is very easy. Thanks!

Great! Did you add a line to set the GPIO pin that was on the second relay to high, then low to get everything going?

I just added lines

/usr/local/bin/gpio write 2 1
/usr/local/bin/gpio mode 2 out

in start up script. You also have to change .php and java script file. Srungi posted them in comments.

koritsi1 month ago

Can you please give some more details on the web page? can you upload the code for the web page? I am using html css and javascript to create the web page but still I'm unsure how to control it.

All of the webpage information (including the zip file with the entire web page contents) are in step 4.

MobileGenius made it!1 month ago

Very nice write up, can confirm all above steps work in order on the Pi2. I have simple (and reusable) prototyping boxes, panels, plates, lids, etc so when it came down to installing this feature to our home automation suite this instructable was a blessing!

This will eventually become fully enclosed and built within a housing. All the components you see are mounted on the bottom of the lid of the enclosure, I'll be building everything into the base as well as adding controls for the second door.

I have seen many different options for reading the status of the door itself. Everything from linear codes reading shapes to full blown live cameras. I'm planning to use a simple distance sensor ($8 for two) facing down from the opener itself. It will relay the distance to either the ground or the door (when it's opened) to the server homepage. This data will be set as a variable and will simply show "Open" or "Closed" using < > codes, with the accuracy of these sensors it should prove reliable.

Happy to see so many people have made sucessful projects and a big thank you to quartarian for the write up!

IMG_0875.JPGIMG_0876.JPGIMG_0873.JPG
ShawnT42 months ago

Thanks for the instructions, works perfectly with my garage door opener (although mine isn't near as nicely mounted as yours.

MikelR made it!2 months ago

I spent a bit more money for a case, and used double sided tape to attach to the bottom of the garage door opener, also attached the relays to the top of the RPi case. Instructions were awesome. This was my first Pi Project!

2015-02-11 18.33.24.jpg2015-02-11 18.33.30.jpg2015-02-11 18.33.46.jpg
MikelR2 months ago

Havent hooked it up to my opener yet, but I got the button, and I hear the click. I verified the loop with a multi-meter. I'm excited to set this up tonight!

isyn.gaming3 months ago
I have a really n00b question. Is the Pi supplying power to the relay to function? For the purpose of testing, prior to getting up on a ladder. Should the relay make the clicking noise if I have all the pins connected correctly from the pi to the relay, but nothing connected on the garage door side of the relay? If so where do I go to see logs of the website trying to fire off the GPIO?
quartarian (author)  isyn.gaming2 months ago

Yes and yes. If it is wired correctly and you don't hear a click, your power supply probably isn't strong enough.

Regarding logs, log into your Pi as root and run this command:
cat /var/log/apache2/access.log | grep ?trigger=1

Good luck!

Panais954 months ago
Please help me. My garage khas two buttons one to open and one to close and I can only open it. How to add another button to use the other relay???
JohnJ6 Panais953 months ago

Mine too but i got it worked out. you still need help?

BobB84 months ago

am I able to use a raspberry pi type B or does anyone know where to find type A. I am new to this and am unable to find where you purchase the type A.

W4rl0ck BobB83 months ago

Any model Pi will do. You should be able to purchase a Raspberry Pi model <whatever> from RS Components - http://www.rs-components.com/index.html - they have distributors that service most areas of the globe.

Panais954 months ago
Please help me. My garage khas two buttons one to open and one to close and I can only open it. How to add another button to use the other relay???
jeff.cartwright.562 made it!5 months ago

I did the happy dance too! As a newbie, I documented everything I did and ended with 27 steps. I added several new steps and expanded on the ones I did understand. It took 3 weekends, but only part-time. Most of the time spent was documenting all of the steps (and about 3 hours typing in the wrong command, expecting a different result). Many of the new steps were just setting up the Raspberry Pi.

One addition was improving the UI, see image. I used paint to add the Raspberry Pi logo to a Genie opener. The Raspberry Pi logo lights up when the button is pushed.

Other additions are: #19 add dynamic DNS, so I don't have to remember the IP address; #21 generating two way self signed SSL certificates; #22 installing client-side certificates on an android, apple or PC/MAC browser; #23 blocking all ports on the Raspberry Pi; and #24 disabling port forwarding on the wi-fi router. These steps prevent anyone on the internet from opening your garage door, while eliminating the need to enter a password.

remote-press.jpg

Hi jeff.cartwirght.562,

I am interested in your setup, especially the certificates for authentication. I feel like I saw your project somewhere before but cannot find it now. Is your project published anywhere or would you mind sharing it?

Thanks!

This was the best source: MakeThenMakeInstall. And here is a cut-and-paste from my version. Items in angle brackets should be replaced with your values. For example, <Raspberry Pi IP> = 192.168.1.76

Step 25: Creating server/client certificate pair using
OpenSSL

SSL facilitates encryption and trust allowing a web browser to validate
the authenticity of a web site. However, client SSL certificates can be used to
authenticate a mobile or laptop device to a web server.

A server/client certificate pair prevents unauthorized users from
opening the garage door. For a client device to open the garage door, it must
have the client certificate installed.

Also, you might to create a unique client-side cert for each device or
user, which would allow you to revoke a license at a later date.

Open a
terminal window on the Mac (I used a MacBook, but any computer is fine) and login

$
ssh pi@<Raspberry Pi IP>

login:
<Password>

Generate
Certificate Authority (CA)

Before creating server/client
certificate, setup a self-signed Certificate Authority (CA), which can be used
to sign the server/client certificates. Once created, the CA cert will act as
the trusted authority for both your server and client certificates (or certs).

$ sudo openssl req -newkey
rsa:4096 -keyform PEM -keyout ca.key -x509 -days 3650 -outform PEM -out ca.cer

pass phrase = <Password>

Generates: ca.cer, ca.key

Generate
Apache server SSL key and certificate

Generate server.key:

$ sudo openssl genrsa -out server.key 4096

Generate a certificate generation request.

$ sudo openssl req -new -key server.key -out
server.req

Use the certificate generation request and the CA
cert to generate the server cert

$ sudo openssl x509 -req -in server.req -CA ca.cer
-CAkey ca.key -set_serial 100 -extensions server -days 1460 -outform PEM -out
server.cer

Clean up – now that the cert has been created, we no
longer need the request.

$ sudo rm server.req

Install the server certificate in Apache

Copy the CA cert to a permanent place. We’ll need to
specify our CA cert in Apache since it is a self generated CA and not one that
is included in operating systems everywhere.

$ sudo cp ca.cer /etc/ssl/certs/

Copy the server cert
and private key to permanent place.

$ sudo cp server.cer /etc/ssl/certs/server.crt

$ sudo cp server.key /etc/ssl/private/server.key

Activate the SSL module in Apache.

$ sudo a2enmod ssl

Activate the SSL site in Apache

$ sudo a2ensite default-ssl

Disable the HTTP site

$ sudo a2dissite default

Edit the config file for the SSL enabled site and add
the lines below:

$ sudo nano /etc/apache2/sites-enabled/000-default-ssl

SSLCACertificateFile /etc/ssl/certs/ca.cer

SSLCertificateFile /etc/ssl/certs/server.crt

SSLCertificateKeyFile /etc/ssl/private/server.key

Apply the config in Apache.

$ sudo service apache2 restart

Right now if you visit your https site, you will get
an SSL error similar to “SSL peer was unable to negotiate an acceptable set of
security parameters.” That is good – it means your site won’t accept a
connection unless your browser is using a trusted client cert. We’ll generate
one now.

Generate a private key for the SSL client.

$ sudo openssl genrsa -out client.key 4096

Use the client’s private key to generate a cert
request.

$ sudo openssl req -new -key client.key -out
client.req

Issue the client certificate using the cert request
and the CA cert/key.

$ sudo openssl x509 -req -in client.req -CA ca.cer
-CAkey ca.key -set_serial 101 -extensions client -days 365 -outform PEM -out
client.cer

Convert the client certificate and private key to
pkcs#12 format for use by browsers.

$ sudo openssl pkcs12 -export -inkey client.key -in
client.cer -out client.p12

[SKIP for now] Clean up – remove the client
private key, client cert and client request files as the pkcs12 has everything
needed.

$ sudo rm client.key client.cer client.req

Step 26: Add Client-side certificate to devices

Lastly, import the .p12 file into your browser.

To copy client.p12 from the Raspberry Pi to a Mac,
open a terminal window and enter the command:

scp pi@<Raspberry Pi IP>:client.p12
/Users/<your MacBook username>

Double click the file to import into the operating
system’s keystore that will be used by IE and Chrome.

For Firefox, open the Options -> Advanced ->
Certificates -> View Certificates -> Your Certificates and import the
certificate.

For Android phones, the browser must be Chrome.

Email client.p12 as an attachment

Open the email on the Android phone and save the
attachment to downloads

Go to home screen and open settings

Security

Credential Storage

Install from device storage

Open the client.p12 file

Enter passphrase: <Password>

Use the awful, default name

For Apple phones, email the cert and double click on it,
then follow the directions.

Email client.p12 and ca.cer as attachments

JamesK64 months ago

Great instructions!
I did have an issue where the relay would just stay on after pressing the butotn (constant red light) and I couldn't get the button (or even the physical garage buttons) to work again without manually entering "/etc/init.d/garagerelay start" into my ssh session with the pi. I'm not sure if this is just because I have a very old garage door opener or what, but I fixed this by editing the php to this -


exec('gpio -g write 4 out');

usleep(1000000);

exec('gpio -g write 4 in');

exec('/etc/init.d/garagerelay start')

;

after that, it worked like a champ!

rfc791 made it!5 months ago

Now to get it to work in SUBFOLDERS! GRRRRR i got a second relay i can trigger my light with, but this thing is not happy anywhere but root.

GaragePi.jpg
OsirisV5 months ago

Great tutorial. Quick question. Everything is working fine but it appears that the Genie series 3 openers don't activate by shorting out the wall opener pins. Has anyone seen this. Will I have to connect my relay to the PCB of the wall control?

Thanks

joeoz6 months ago

I have wired up my Raspberry Pi to the first module of my Songle relay board. When I click on the big button on the web page I can hear a clicking noise on the relay and see the red led light up. Unfortunately I am having a hard time figuring out how to wire up the relay to the PCB on my garage remote. I have figured out the switches on the remote which trigger the garage door open but I am struggling to find the solder points on the back of the PCB where I can solder my wires to.

Also can I use CAT 6 wires to wire the relay to the remote?

My garage door is Gliderol and I have attached pictures. Can some one please guide me on how to get this right. Many thanks in advance!

Remote_Front.JPGRemote_Back.JPGGarageDoor_Relay.jpg
al_carr6 months ago

Poop.

Great idea,, been looking for something practical to do with one of my Pi's. I cycle a lot and this will eliminate the need to carry an opener or park outside and run inside to close the door... all this after trying to call a head and not have my wife or daughter answer either their cell phones or the home phone.

Got it all setup but the webpage doesn't seem to want to trigger the relay.

Tested using cli, "gpio" command work to toggle GPIO7 up and i can hear the relay clicking.

Using the web page I get the big button but when i press it nothing happens. Monitoring GPIO7 it stays high when I click the big button.

Not sure how to troubleshoot this further. Any ideas of what I might have done to mess this up. :-)

thanks,

Al

al_carr al_carr6 months ago

I've implemented a work around by putting in a script that toggles GPIO 7 for 1 second and then put that script in my .bashrc. So all I have to do is open my SSH app on my phone and select my raspberry pi the door opens.

Still would like to know how to trouble shoot the original issue for the learning experience if anyone has ideas.

thanks,

Al

ErikF26 months ago

Don't know the specifics but the jquery.min.js in the zip file wouldn't work with my IOS 8.02. Hence I deleted that line and replaced with the google api of <script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> worked like a charm after that.

AndrewD46 months ago

I followed the instructions almost to the T, and it worked awesome. When the door first opened I did the happy dance. I purchased some female to female breadboard jumpers for making the connection to the relay that worked great. Thanks for this instructable!

1-40 of 105Next »