Remote-Garage-Door-Controller
Remotely monitor and control your garage door through Particle Cloud, IFTTT, and/or Alexa, for ~$25US.
Hardware:
At the heart of this project is a wifi-enabled ESP8266-based Digistump Oak MCU ($10), connected to the Particle Cloud. An HC-SR04 ultrasonic range finder ($2) attached to the Oak measures distance from the sensor, installed in the rafters or from the ceiling of your garage and pointing downward, to either the rolled-up garage door, your car, or the floor of the garage. Range measurements are interpreted as one of three states: the garage door is open, the garage door is closed and a car is present, or the garage door is closed and no car is present. A Digistump 3V Relay Shield ($7) connects the Oak to your garage door opener's momentary toggle button terminal (in parallel with any existing garage door opener button you already have in your garage). Optionally add a DHT11 temperature/humidity sensor ($5), because... why not?
Repository Contents:
| File | Target | Description |
|---|---|---|
| AlexaSkill.js | Amazon Lambda Function | Library (v2.0) containing essential Alexa interface functions. This file was provided in examples at one point, and may be obsolete, but works fine for this project at the time of this writing. |
| index.js | Amazon Lambda Function | Custom interface between Alexa and Particle Cloud |
| GarageDoorController_AlexaSkill_IntentSchema.txt | Alexa Skills Kit | Custom Skill Configuration |
| GarageDoorController_AlexaSkill_Utterances.txt | Alexa Skills Kit | Custom Skill Configuration |
| garage_controller.ino | Oak | Arduino sketch for Oak, configures Particle interfaces and handles hardware functions |
| GarageDoorController_fritzing.jpg | Fritzing diagram | |
| GarageControllerHardwareLayout.jpg | Physical topology | |
| GarageControllerRemoteInterfaces.jpg | Remote interfaces block diagram |
Remote Interfaces
Particle Cloud Interface:
Once the hardware has been configured and installed and firmware flashed, key variables and states from the sketch running on the Oak will be available for remote viewing via either OakTerm, the Particle mobile app (iOS or Android), or through a custom app or html5 page. You can also use these interfaces to send "open", "close", "toggle", and "check" commands to the Oak (as string arguments to the command() function). The Oak publishes events to the Particle Cloud when the door opens or closes, when a car arrives or departs, and when the door has been left open for an integer number of hours.
IFTTT Integration:
Events published from your Oak to the Particle Cloud may be used as triggers for IFTTT recipes to alert you when the garage door opens or closes, a car arrives or departs, or when the garage door has been left open for an extended period of time. You can also use IFTTT to automatically respond to "door opened for X hours" events by sending the close command to the controller.
Alexa Integration:
You can also interface the Garage Controller through Alexa by creating a custom skill and an Amazon Lambda function. The Lambda function, which you can create using the included deployment package (index.js + AlexaSkill.js), serves as a necessary middle-man between Alexa and the Particle REST server. The lambda function receives JSON-formatted requests from the Alexa skill, sends GET/POST http requests to the Particle REST API, parses content returned from the Particle cloud, and generates JSON responses to send back to Alexa. Once you have configured and linked your custom skill, you will be able to verbally ask Alexa to check the door state or to command the door to open or close. You will need a (free with limitations) Amazon developer account to create custom skills and lambda functions. The process of setting up the custom skill and lambda function should take on the order of one hour if you are familiar with developing custom skills, and a bit longer if you're learning as you go.
Deployment procedure:
- Connect the range sensor, relay shield, and (optional) temperature/humidity sensor to the Oak as shown in the attached diagram.

- Flash the garage_controller.ino to the Oak.
- Experiment with range sensor measurements, using OakTerm, the Particle mobile app, etc, to verify general functionality.
- You can test the range sensor and sketch prior to installation in your garage.
- After installation, you may need to reconfigure the range values according to the height of the sensor.
- Install the Garage Controller in the garage.
- The range sensor must be positioned above where the roll-up door rests when open, and also above where the car parks.
- Connect the relay to the terminal block on the garage door opener, or splice into wires going to an existing garage door toggle button.
- Test the configuration via OakTerm, the Particle mobile app, etc.
- If everything works well, you now can remotely check the state of the door and command it to open or close.
- Create IFTTT recipes
- IF device "MyOakDevice" published new event "state_changed", THEN send notification "[EventTime] [DeviceName]: [EventName]: [EventContents]"
- IF device "MyOakDevice" published new event "hours_open", THEN send notification "[EventTime] [DeviceName]: [EventName]: [EventContents] hours"
- IF device "MyOakDevice" goes offline, THEN send notification "[DeviceName] has just gone [Status]"
- Create your Garage Controller lambda function.
- Edit the DEVICE_ID and ACCESS_TOKEN constant strings in index.js.
- Zip index.js and AlexaSkill.js into a single zip file (with no subdirectories in the zip).
- Create a new Lambda function using a blank template or any NodeJs template.
- Upload the zip file.
- Copy the ARN from your new Lambda function.
- From the Amazon Developer Console, navigate to the Alexa Skills Kit, and add a new skill.
- Name your skill "My Garage Controller", or something that sort of works with the phrase "Alexa, ask [My Skill Name] to ...".
- Copy the content of GarageDoorController_AlexaSkill_IntentSchema.txt into the Intent Schema field.
- Copy the content of GarageDoorController_AlexaSkill_Utterances.txt into the Sample Utterances fieldl
- On the Configuration page, select AWS Lambda, North America, and paste your ARN into the text field.
- Test your configuration using the Service Simulator on the Test page. Enter "check status" in the Enter Utterance field, and press Ask. If the Lambda function is working and correctly linked, you will see a json response in the Lambda Response field. Click Listen to hear how this reponse would sound through Alexa.
- Once you get the skill working in the Service Simulator, you are ready to test with your Alexa device. On the Test page, Enable the skill for testing on your account. You don't need to install the skill on Alexa. Just ask Alexa "Alexa, ask My Garage Controller to check if the door is open". You don't need to finish the Publishing Information or Privacy and Compliance pages (do not publish the skill, but rather use it perpetually in test mode).
Please leave a comment if you found this useful or if you have any questions or suggestions.
Cheers!

