This is a raspberry pi project that enables you to open your garage/gate with any kind of web browser!

Step 1: Gather Those Supplies.

  • Raspberry Pi - 35$
  • Relay Board - 5$
  • Your Gate Opener - (You will be sacrificing the gate opener)

Great. Now that you have those, moving on!

Step 2: Wire Up That Remote.

Crack open your gate opener and find where the button leads are. Solder two wires to the leads. When you touch these wires together, your gate should toggle. At the time of making this I didn't know much about circuitry so i went a head and soldered the button, so that when power was supplied to the remote, the gate toggled. YOU DO NOT NEED TO DO THIS. Just solder the two wires to the button leads. And then solder those wires to the relay.

Step 3: Wire Up That Relay.

Find the pins on the relay that are labeled GND and VCC. Connect the VCC to the raspberry pi's 5v pin. You can find a mapping of the pins here: http://elinux.org/RPi_Low-level_peripherals. And wire the IN1 to one of the Pi;s GPIO pins. Your choice of which pin. Check out that link above to see which ones are ok for this. (make sure you're using relay 1 if you're relay board has more than relay channel.)

Step 4: Get That Library.

SSH into your pi or get the CLI somehow so we can install some things.

First install RPi.GPIO. Just search google for it and download it to your pi. It's a very easy install of the python library. If you have any problems, try running as root through the entirety of the installation.


Step 5: Write That Code.

In this tutorial I will include the very first version that I created. I have expanded on this by a ton so if you want my code, just comment. Mine includes access codes that expire and a full web application that secures the gate web interface and remembers your password for next time. But here we go with the simple version. Install apache web server on your Pi. It is very easy! Look for tons of tutorials on google for this! After you've done that, here is the php code:

Create a file called index.php and put this in it. make sure the file permissions are set correctly after this...chmod 777.



exec("touch /var/www/key.txt",$output);


Step 6: Write More of That Code.

Ok, now the python code. Put this in the same directory as Index.php. On my pi that is /var/www/. Here is the python code:

import os.path

import os

import RPi.GPIO as GPIO

from time import sleep


GPIO.setup(11, GPIO.OUT)

while True:

if os.path.isfile('/var/www/key.txt'):

GPIO.output(11, False)


GPIO.output(11, True)


GPIO.output(11, False)


Make sure that you make it executable. Chmod +x.

Step 7: Putting It All Together.

Ok, so you've got the code in and permissions perfect. Now it's time to start it up. SSH into your pi and run the python script in the background using &. If you are confused by this, google it. This tutorial is meant for people who have at least some experience with CLI.

Great! Now visit you Pi's IP address in a web browser and you're gate should open! (The remote is toggled.)

If you have any questions, I invite you to comment! I hope this tutorial is clear because it was my first instructable. :) Good luck!

<p>great instructable.</p><p>My wife just broke both her ankles in a holiday accident! so I needed a way to phone-enable the gate for her.</p><p>following your steps, I pulled this together in about 90 mins this morning</p><p>I plan on integrating this with one of the HD Security Cam Instrictables out there, so I'm saving on Pis. :)</p><p>thanks!</p><p>D.</p>
<p>Oh man! So sorry about your wife. I hope she has a quick recovery! You honestly just made my day by commenting. Thanks! That security cam idea sounds cool as well! I'm beyond happy this was so useful to someone :D! My family and I use it almost every day!</p><p>- Sam</p>
i hare Ron. :)<br><br>have a look at HomeGenie integration vid.<br><br>https://youtu.be/6duEAJsoq_I<br>
Hey Sam<br><br>thanks for.the well wishes.<br>ive just integrated it with HomeGenie so i now have voice control of the gate.<br><br>once i refine.it ill throw up a small instructable.<br><br>all the best<br>D
<p>I don't know anything about Raspberry Pi's but I have been wanting to find a &quot;usefully&quot; project to get started with one. I think I have finally found the project. I do commercial security, so I'm very familiar with relays &amp; the like. My question is why do you have to sacrifice the remote, why not just use the relay on the aux relay board (controlled by the raspberry) to short the relay/trigger on the gate operator? I like the idea of your new code that has a interface. Once I get all my supplies, I'll be back in touch!</p>
<p>Hey Sam</p><p>Thank you for sharing. I am totally new in home automation.I'm more into industrial automation [PLC and all] but now i'm planning to realize that project for my dad house. </p><p>Your project is nicely explain and seems to be very easy I'm going to do it and get back to...</p><p>Thanks once again for sharing the good work. </p><p>Bello<br></p>
<p>Great write up. I'm interested in building this as well, can you provide your code that also allows access codes?</p>
<p>I am currently busy with school, my apologies for the late reply!</p><p> I originally wrote the access code program in PHP, and about 4 months ago, redid the system with node.js (<a href="https://nodejs.org/en/" rel="nofollow">https://nodejs.org/en/</a>) and made small hardware improvements. I don't have the original code anymore, but I am happy to provide the code that I am using as of now. I really want to add the access code feature into the new one when I have time. I'll post if I end up doing it soon. Thanks for the comment!</p><p>Here is the current node code. Let me know if you need any help understanding it and whatnot. I'm happy to help.: <a href="https://drive.google.com/file/d/0B1je7v44VCFVS3VVMGhaQzhseVk/view?usp=sharing" rel="nofollow">https://drive.google.com/file/d/0B1je7v44VCFVS3VVM...</a></p><p>- Sam</p>

About This Instructable




Bio: I build cool stuff.
More by sam1999:Raspberry Pi Gate Opener 
Add instructable to: