Raspberry PI Zero Garage Door Opener Using Blynk

18K7324

Intro: Raspberry PI Zero Garage Door Opener Using Blynk

Ever lose a garage door opener and looked for a replacement on Amazon? The replacements for my garage door were $20-$30. I figured I'd make one using a $10 pi zero (Ok for like $30 after all accessories) but at least I can use it to control my garage from anywhere I am connected to the internet.

Materials:

PI Zero Wireless and all accessories (power supply, gpio header, case, etc)

4 channel Relay (you can use a 1 ch or 2 ch, but the price difference for 4 ch was very little so I bought the 4 ch)

Blynk app (App store and http://www.blynk.cc/ )

If you can follow instructions and have some linux/unix experience, you should be able to do this pretty easily.

STEP 1: Setting Up Software Raspberry Pi

Software on Raspberry Pi:

There are many different combinations that will work, I tried to be clear but also not too specific as there are many variables, if you have questions just ask. Also, if be sure to check out my video for additional help.

1. Install latest Raspian OS from here (or any other Linux OS)

2. Double check to make sure WiringPi is installed. Instructions here: http://wiringpi.com/download-and-install/

3.Follow Instructions for Manual Node.js installation; Check your Node.js and npm installation; and then Install Blynk globally found here http://help.blynk.cc/hardware-and-libraries/node-...

**Note: When you get to the "Run default Blynk client", there is a reference to authentication token. This will be emailed to you when you setup a project on the blynk app on your mobile device in a later step.

4. In order for blynk to start automatically after reboot, I edited the /etc/rc.local file as such:

- in terminal type this: sudo nano /etc/rc.local
- add: "sudo blynk-client &" after: fi

- then Control+X to exit, confirm save.

- test it with sudo /etc/rc.local start

STEP 2: Wiring 4 Ch Relay to Raspberry PI

First step is to solder a GPIO header to your Pi zero (assuming it doesn't have one, mine didn't). I have a video of this here or you can find other videos on how to do this. https://www.youtube.com/watch?v=gtCwC4VAQZo&t=4s

Next, reference the pin diagram to find the pins you need for the project. For this project, we need 1 5v (pin 4) 1 ground (pin 6) and 2 gpio pins which will control 1 garage door switch each (pin 3 and pin 5).

Then connect each pin to respective pin on the 4 ch relay. They are clearly labeled on the relay.

GND = ground (pin 6)

VCC = 5V power (pin 4)

IND1 = garage door 1 (pin 3)

IND2 = garage door 2 (pin 5)

Now that is done, lets move on to the blynk app.

STEP 3: Configure Blynk App

First you need to download the blynk app in the app store. You will be asked to create a profile after install.

Next, create a new project (very intuitive in the app). When you do this, blynk will email you an access code. Don't share this as this is how you will sync your phone to your raspberry pi. If you recall, back in step 1 you needed an access code to start the blynk client. This is that access code. Copy it from email and log in to your raspberry pi and paste it.

Now to configure your project:

-This blynk project will need 2 buttons, 1 to control each garage door as mentioned before. To add a button, click the + button on top right of the project. you will see option for button. Get 2 of these.

-Each button will need to be configured separately.

There are 3 things to configure:

Output - which is choosing the pin that the button will control

Mode - Push vs Switch, Push is a momentary switch which triggers the output while only as the button is pressed, when released, it will go back to the pre-pressed value. Switch is different, when pressed, switch will trigger the output and when release will stay on the triggered value and would need to be pressed again to switch back to pre-pressed value.

Labels - basically naming the button and the values.

Button 1 - output should be gpio 2 (pin 3) and set to push, I labelled mine Main Garage

Button 2 - output should be gpio 3 (pin 5) and set to push, I labelled mine Shop Garage

STEP 4: Put It All Together

Before finishing the install, I suggest testing everything before spending the time putting all the final touches on the wiring to prevent from having to do it again.

So I wanted my garage door to function both with the physical switch and also the blynk app. My garage door open and close mechanism is triggered by shorting 2 terminals. Basically, the physical button does this when pressed and same with the relay when the virtual button is triggered on the app. The wiring is very simple and is better explained with pictures than with words. So please reference the pictures.

After you wire it up, install it,add power to the raspberry pi and you are all set. Enjoy!

Here is the video of the project also, between the instructable and the video I hope this helps you with your project. https://www.youtube.com/watch?v=gYN38XgH2fM If you have questions, please feel free to ask a question in the comment section.

18 Comments

I had trouble with the start after reboot. Instead of your line on the /etc/rc.local

I used:

/home/pi/blynk-library/linux/blynk --token=<your token> &

This edit worked for me as well. Thanks to you both for the information you both provided. However, there is a problem. When I simulate a power loss by disconnecting and then reconnecting the Pi's power plug, once the Pi boots, the relay light comes on automatically which suggests that a reboot will cause my garage door to open as a result of the reboot (I don't have anything connected to my garage opener yet). I have to press the button in the Blynk app to turn the relay off. Any suggestions on how to resolve this issue? Thanks!

From what I gathered from the datasheet of the GPIO there are some pins that by default have their state change to on after reboot or shutdown. You can change it by changing some configuration files or what I did in my case since I only needed one relay since I have one door was to switch from PIN 3 (GPIO 2) to PIN 7 (GPIO 4) and that solved my issue. You can find more information here - https://www.raspberrypi.org/documentation/configuration/pin-configuration.md and https://www.raspberrypi.org/documentation/hardware/raspberrypi/bcm2835/BCM2835-ARM-Peripherals.pdf
I had the same problem, so I put the project aside for a while. When I was attempting to solve it, I read several forums with no luck. I am still on the search for the answer, but, I wanted to try another relay for an LED.

The second relay won't turn on on startup, so I tried changing the pin for my garage door (or future garage door). Blink will always keep the first pin live on startup.

So you may try adding two pins on blink, and add the door opener to the second one. Let me know if you find a solution for this.

do you have a close up of your wiring for your relay on the relay side? Make sure you don't have it wired for normally closed, which probably means you have the blynk app setup for normally open configuration, which gets triggered when you use the app causing the "normal" operation mode. Let's start there.

Hi, Can you tell me how to do the wiring from the relay to the actual garage switch ?

Tried following the instructions in part 4 to get Blynk to start after reboot but although

"sudo nano /etc/rc.local" appeared to take me to the right place, I couldn't add the specified text, any ideas what I might be doing wrong?

I think you're in the wrong directory to do this.

cd .. a couple of times and ls until you see "etc"

then cd etc

sudo nano /ect/rc.local

I had to add the entire start routine to the rc.local file to get it to start up.

I added

export PATH=$PATH:/opt/nodejs/bin/

unset NODE_PATH

blynk-client YourAuthToken

Thanks I will give it a try, still learning.

In the Blynk app I didnt see an option for the board to be pi zero, I saw the other versions. What did you select? PI 3 B ?

I used Pi 2/A+B+ (WiFi) and it worked

Is connecting the relay to the actual garage doors as easy as programming a new garage door remote?

Cool!

Do you have link to your 4 ch relay product page?

I also had trouble with setting up blynk, instead I followed instructions here

https://github.com/blynkkk/blynk-library/blob/master/linux/README.md

Im glad you were able to get your set up working! Can you help me understand where you were having trouble so i can clarify my instructable?