Twilio SMS Powered Garage Door

Twilio SMS Powered Garage Door

 Overview


Example code for this project can be found here https://github.com/cbackescom/TWLO-Particle-GarageDoor

This example will enable you to turn your dumb garage door into a smart bot that you can ask questions. Make sure if you use this code you protect your communications to/from Twilio by hardening the communication. Encryption and password protected URLs are a must for this type of project. Information captured on the open Internet that allow an attacker to obtain entry into your garage/home is dangerous. I have not included a security code in addition to the security steps outlined below so use at your own risk!! Twilio Authy would be something you might want to add to this project as well.

PHP Server Code


First, you will need to find a place to host the example PHP code. To get started, I would recommend developing locally and just exposing the code from an ngrok url. If you are more comfortable in Javascript, take a look at Twilio Functions. Below is a breakdown of the example PHP code.

  • Create an array to hold all the contacts we want to grant access to sending commands to the garage door.
  • Check incoming requests from Twilio to verify ‘From’ is equal to a number in our array.
  • Run variables through comparison logic to determine what action we want to take.
    • Retrieve the ‘status’ of the doors, are they up or down?
    • Open or close either of the doors.
    • Actions are sent to Particle.io API.
  • If user is not in approved list, deny and give them a message indicating so.

Hardware List/Installation


After you have your PHP code served up, it’s time to fire up your Particle device (Photon in this example) and flash some code! I will not go over that process in it’s entirety, but it is as simple as copying my example code into the Particle Web IDE and flashing the device.

Once you have your code flashed, you are all set to connect all the pieces. First plug in your photon (with headers) into the Relay Board. Next, plan out how you will mount the Relay Board near your garage door drive motor unit. I determined this is the best place to locate the device since we will need power and direct connections from the relays to the garage door drive motor unit. You will also want to run a wire between the output of your relay to the terminals on the back of drive unit. You will want to use the same terminals that come from the wired remote in your garage. Below is an example of how you can connect things.

 

Twilio Setup


Similar to any other Twilio project, make sure you have your account created. If you do not, head on over to Twilio and get signed up now! After you have your account setup, purchase a telephone number if you do not already have one. While you are purchasing, make sure you buy one that has the SMS capability since we will be using SMS 🙂

 

Once you have your new number, head to PhoneNumbers->ActiveNumbers in your console and click on your new number.

Leave a Reply

Your email address will not be published.