I borrowed my brother’s iPhone in order to capture the video.
My dad and I made a wifi garage door opener and status checker.
We did this project crazy-fast and without any hang-ups, which was interesting to me because it showed how far along the tools have come.
- Original Raspberry Pi
- 1x Opto-isolator
- 1x Reed switch
- OS: Nerves (Linux boot to Erlang)
- App: Custom Elixir app source
- App: Custom Ionic app source
Our garage door opener has a physical panel just outside where one can enter a 4 digit pin and open the garage.
After some fairly recent rain storms, the panel has been malfunctioning and fails to work 95% of the time. It’s not a battery issue.
It was expensive to replace that from the manufacturer, and we didn’t want the same faulty product!
We want to know if the garage door is open or closed and be able to open or close it remotely.
This would take two GPIO pins.
read logic level 1 or 0 based on the garage door being open or closed. a reed switch affixed to the door’s frame, adjecent to a strong magnet on the door, will do the trick.
write logic level 1 to a circuit that simulates a button press on the garage door manual switch, located inside the garage. We used an opto-isolator for this.
I used Nerves on an old Raspberry Pi.
Nerves makes it possible to create minimal ARM firmware that boots directly into the Erlang virtual machine (BEAM).
Essentially it helps you compile a barebones linux kernel with the init system replaced.
I chose Nerves because I like Elixir and the emphasis placed on making fault-tolerant systems right from the start. I think it’s quite apt for the embedded space.
After making Nerves development easier on Mac, I started the project.
Controlling GPIO pins was easy to do thanks to Elixir ALE.
The core concept is to listen on HTTP and allow read/write on any GPIO pin:
Credit goes 100% to my dad for all the circuit design and prep downstream of the GPIO pins. If you’d like to replicate this look at the reference schematics for an appropriate voltage reed switch and opto-isolator.
A Normally Open (NO) Reed Switch and a magnet are used as the Garage Door status sensor. The Reed switch is installed on the frame, and the magnet on moving door. When the door is in the closed position, the switch short the PI’s input to ground indicating logic “0,” otherwise that input is in logic “1.” We chose a passive Reed magnetic sensor over hall effect transistor because the latter would have required access to a supply voltage and therefore we would have to run 3 wires from PI to the sensor.
All I had to do was put the board together with the Raspberry Pi:
Prior experience indicated that Ionic would make the mobile app development portion trivial.
The core concept for the mobile UI here was to list one or more “things” that have state and can be toggled:
The core concept for the controller was to provide the list of “things” that know how to fetch state and be toggled:
This code could definitely use improvement (and reveals other problems), but this resulted in a decent app:
After soldering the wires from our opto-isolator into the manual switch, we’ve got this:
The last step was hooking up the reed switch to the door. You can see the reed switch in the left of the pic below:
You can see the whole thing in action in the video at the top of this post.