Automated Garage Door using a Particle Photon
Updated: Jan 9, 2019
Automating your Garage Door opening and closing is a great place to start if you are interested in automating your home. Basically, you just need to simulate a button press which is the same as shorting across the button circuit. While there are certainly a few more details than that, it is pretty straightforward. For this project, I decided to use a Particle Photon to control the system, a relay to simulate the button press, and a couple magnetic reed switches to let me know the position of the door (Closed, Opening, Open, and Closing). This project can be completed for easily under $100 and is a lot of fun once you get everything working properly. For bonus points, I added this to my personal Android home app so I can control everything from my phone (Future blog post on this soon...).
BILL OF MATERIAL (HARDWARE)
** In addition to the above main components, you will also need some various hook-up wires, a breadboard for testing, and a few other basic components from your standard maker kit.
Files for this project are stored on GitHub here: https://github.com/bradharbert/AutomatedGarageDoorOpener
INO file - Code (Firmware) for your Particle Photon
Fritzing file - If you use Fritzing, this includes the breadboard and 2D sch
Simulating a Button Press
First step was to determine how I could simulate a button press - either from the mounted remote on the wall of the garage, on the opener unit itself, or through the remote I use in my truck. Since there are a lot of different garage door opener models and brands out there, your method may be completely different than mine. For my application, I wanted to keep the wiring through the garage at a minimum, so decided to sacrifice the remote and mount it near the wall unit.
Basically, open up the remote and pull out the PCB (printed circuit board). From there, find the terminals where the button is attached to and you are good to go. All you need to do is wire your relay up to these 2 terminals so when you want to open or close the door, the relay will short across these 2 terminals simulating a physical button press.
Is the Door Open or Closed?
Next step is to install a couple magnetic reed switches that will tell the general position of the door. Reed switches can either be On or OFF, based on the location of the matching component. In the "Closed" state, one of the reed switches has continuity while the other is open - and vice versa. By writing a little code for the Photon, I developed a state machine that would determine the door location based on the combination of the two reed switches and what their state was.
So this approach required installing a reed switch at the base of the garage door opener and a second switch on the horizontal rail to capture when the door was completely open. I installed these in 2 stages - when the door was closed and open and both stages have the corresponding reed switch's matching up so they complete their respective circuit.
Developing the Circuit
The circuit is pretty simple - The Reed Switches hook up to the Photon's D2 and D4 pins to let me know what position they are in. They have 2 wires and which ones you connect to the digital pins or ground do not matter. However, when I originally connected them I was not seeing the results I was expecting. After some Googling and research on the Particle Forums, I found that adding the resistors (R1and R2) solved the problem.
In regards to the relay, it is important to note that the Particle Photon operates at 3.3V as opposed to the standard 5V that you may be used to working with on an Arduino. That being said, I had a couple 5V relays already lying around to use, but they did not work. Therefore, if you have relay operating problems, make sure you are using a 3V relay. This one worked great!
Wiring it Up
For this project, I wanted to make it "Semi Permanent" so decided to use a prototyping board and actually solder most of the connections as opposed to dropping in a breadboard. All of the soldering is under the prototype board to help it look a little cleaner. I used some basic metal standoffs and drilled the holes into the project box. From there, mount the 3 components, wire it up, and get ready to write some code. A couple items to note:
On the Garage Door Opener PCB, I noticed that the button SW4 was being depressed when the main button on the housing was pressed. Knowing that was the button I needed to simulate, I just soldered wires to that buttons terminals. Then, those wires are inserted into the relays COM and NO (Normally Open) terminals. Once again, polarity does not matter here.
The other side of the relay has 3 connections - Power (VCC), Ground (GND), and Input from the Particle pin A0 (IN).
Resistors R1 and R2 are mounted underneath the prototype board so you can't see them in the following image.
Writing some Code
The code is fairly straightforward and commented, so I will not go into too much detail here. However, to monitor the position of the garage door I used a State Machine. This will allow you to know what state the garage door is in (Closed, Door Opening, Open, Door Closing) instead of just Closed or Open.
In addition, I am creating some Particle Variables and Functions so I can (A) monitor the status/location of the door and (B) send the Photon button press commands from the Particle Console, CLI (command line interface), web page, or custom app.
This link provides the GitHub to the .INO file you can use in Particle's Build UI - or Arduino IDE if you decide to go that route.
From a testing standpoint, I put everything on a breadboard first to test out both the relay operating properly and the reed switches being either opened or closed. The reed switches were pretty solid and would close the circuit if the magnets are placed within about 4 to 6 inches of the wired switch. Since really all you are simulating is a button press, not too much can go wrong here. However, definitely make sure you garage door is operating properly prior to installing everything and that the sensor that comes with your garage door is functioning. The only good thing about squashing your dog or wife with the garage door is that hopefully you are in a remote location far from the incident.
Congratulations, you should now have a garage door that you can control from anywhere you have an internet connection. Following is an image of this functionality I have included in my Android app for all my home automation projects. This app will tell me what state the door is, what particle photon I am using, and a button at the bottom to open and close the door. In addition, I created some animation in the app to help visualize the current state. In future blog postings, I will show you how to develop this app and bring in Particle Cloud events for this and several other projects.