Over my break, I decided to start getting into IoT by making my home smarter. I did not want to purchase any of the plug and play devices. The fun part is building these devices. My first idea of home automation is the garage door, since I had all the parts needed to automate it in my junk box.
- Garage door with remote or switch
- 2 resistors
- Solder and soldering iron (optional)
The easiest way to open a garage door is to push the button on the remote. That would be a good starting point for my device.
First, I opened the remote with a screwdriver. On the PCB, I saw the switch that is pushed when I pushed the button. The switch had four pins. To figure out which pins will open the door, I used a small wire to short every two pins until the door opened.
Now that we know which pins need to be connected to open the garage door, we want to connect the pins using a digital signal. That's where the transistor comes in. I did not have any MOSFETs in my junk box, so I had to settle with an NPN bipolar transistor and a resistor.
We connect the transistor's collector and emitter to the pins of the switch and connect the base to a digital output pin on the microcontroller (with a resistor). I used a Teensy 3.2 microcontroller since it's small and inexpensive.
Finally, we connect the ESP8266 to the microcontroller to be able to use Wifi.
The code on the Teensy is pretty straightforward. All it does is start an HTTP server that has a single route (/toggledoor). When a client hits this route, the microcontroller sends a HIGH signal to the transistor for 500ms. This emulates a button press and causes the door to open.
I did not have to write any code on my phone. I used two apps to control the door. The first app is AutoVoice. This app captures whatever I say to Google Now. It has many features for filtering commands and responding to them. I used another amazing app called Tasker to send the HTTP request to my microcontroller. Tasker works with AutoVoice to trigger an action when AutoVoice recognizes a command.
This is all it takes to control a garage door using Google Voice. The next step is to see if I can program the ESP8266 to do all of that without using another microcontroller.