Andrew Pena
Published © GPL3+

100% Hands-Free Garage Door with Visual Confirmation

Controlling access to your garage & home has never been more convenient and secure...100% hands-free!

IntermediateFull instructions provided3 hours13,081
100% Hands-Free Garage Door with Visual Confirmation

Things used in this project

Hardware components

Photon
Particle Photon
Select one only - either the Particle Photon or Spark Core * The Particle Photon is the latest version of the Spark Core and in essence, replaced it. While very similar to each other, there are slight changes but they are 100% interchangeable and are programmed the exact same way. For my project, I used the Spark Core unit.
×1
Particle Spark Core
Select one only - either the Particle Photon or Spark Core * The Particle Photon is the latest version of the Spark Core and in essence, replaced it. While very similar to each other, there are slight changes but they are 100% interchangeable and are programmed the exact same way. For my project, I used the Spark Core unit.
×1
High-Power Relay Shield for Particle Photon I²C 1-Channel SPDT 10-Amp
ControlEverything.com High-Power Relay Shield for Particle Photon I²C 1-Channel SPDT 10-Amp
Select one only - either the Particle Photon Relay Shield, ControlEverything Relay Shield or Spark Core Relay Shield * The Particle Photon is the latest version of the Spark Core and in essence, replaced it. While very similar to each other, there are slight changes but they are 100% interchangeable and are programmed the exact same way. For my project, I used the Spark Core unit.
×1
Power Strip
×1
Digital Reed Switch
×2

Software apps and online services

DO Button - IFTTT
This app acts as the new garage door controller. By building a simple recipe, an icon on your phone can be used to open or close your garage door from anywhere in the world.
Amazon Alexa service
IFTTT Amazon Alexa service
OPTIONAL: If voice control is desired, you’ll integrate a recipe from the Amazon Echo into IFTTT. Very simple to add.
Presence
OPTIONAL: This is a free (limited access) app that allows my old iPhone 4 to be used as a 24 hour camera. In addition to live streaming (real-time), you an opt to record when movement triggers the camera. Personally, I use just the streaming to “peek in” from time to time to be sure the garage door is closed. All that is needed for the phone (or camera) with this app is WiFi access and viewing can be done anywhere in the world.
Pushbullet
OPTIONAL: Use this if you want to receive notifications of a “status” or “door” change.

Story

Read more

Schematics

General Wiring Diagram (1)

This is the general wiring diagram using the Particle Photon and the ControlEverything Relay Shield. While the product(s) may be slightly different, the wiring is generally the same. I’ve included a few diagrams to see how flexible the wiring can be.

Wiring Diagram (3)

Another diagram for wiring. This one shows 2 garage doors.

Fritzing Diagram (2)

Here is another diagram I used to help me get the project completed. It’s a very simple connection and hopefully, with a few diagrams, you’ll agree.

Code

Garage Door Operation

C/C++
This is the simple code that is used for my project. A few things about the code:

1) While I have a REED SWITCH built into the code, I actually don’t use one physically. The original intent to use a REED SWITCH was to provide feedback as to whether the garage was opened or closed. Despite both the hardware and software using a REED SWITCH, I preferred to rely on visual confirmation and as such, now use an old iPhone 4 as a security camera.
2) This code is for (1) one garage door, a second can be added very easily.
// IO mapping
// D0 : relay: garage_BUTTON - this output is connected to the garage wall button or the garage remote
// D1 : relay
// D2 : relay
// D3 : relay
// D4 : garage_CLOSE : high means contact open (garage door opened), low means contact closed (garage door closed)
// D5 : garage_OPEN : high means contact open (garage door opened), low means contact closed (garage door closed)
// D6 :
// D7 :

// A0 :
// A1 : 
// A2 : 
// A3 : 
// A4 :
// A5 :
// A6 :
// A7 :

#include "application.h"

String _version = "0.01";

#define PUSHBULLET_NOTIF "pushbullet"

#define GARAGE_READ_INTERVAL 1000
#define GARAGE_OPEN "open"
#define GARAGE_CLOSED "closed"
#define GARAGE_OPENING "opening"
#define GARAGE_CLOSING "closing"
#define GARAGE_NOTIF "GARAGE"
unsigned long garage_interval = 0;
int garage_BUTTON = D0;
int garage_CLOSE = D4;
int garage_OPEN = D5;
String garage_status_string = "unknown";


void setup() {

 Particle.publish("device starting", "Firmware version: " + _version, 60, PRIVATE);

  pinMode(garage_BUTTON, OUTPUT);
  pinMode(garage_OPEN, INPUT_PULLUP);
  pinMode(garage_CLOSE, INPUT_PULLUP);
  
  bool success = Particle.function("garage_open", garage_open);
  if (not success) {
      Particle.publish("ERROR", "Failed to register function garage_open", 60, PRIVATE);
  }
  
  success = Particle.function("garage_stat", garage_stat);
  if (not success) {
      Particle.publish("ERROR", "Failed to register function garage_stat", 60, PRIVATE);
  }

}

void loop() {
 
  //read garage status every now and then
  if( millis() - garage_interval >= GARAGE_READ_INTERVAL ) {
    garage_read();
    garage_interval = millis();
  }

}

/*******************************************************************************
 * Function Name  : garage_open
 * Description    : garage_BUTTON goes up for one second
 * Return         : 0
 *******************************************************************************/
int garage_open(String args)
{
    digitalWrite(garage_BUTTON, HIGH);
    delay(1000);
    digitalWrite(garage_BUTTON, LOW);

    return 0;
}

/*******************************************************************************
 * Function Name  : garage_read()
 * Description    : reads and publishes the status of the garage, intended for using it with a service like ifttt
 * Return         : 0
 *******************************************************************************/
int garage_read()
{
    int open = digitalRead(garage_OPEN);
    int closed = digitalRead(garage_CLOSE);
    String previous_garage_status_string = garage_status_string;
    
    //input goes low when the reed switch is activated
    if ( not closed ) {
        garage_status_string = GARAGE_CLOSED;
    }

    //input goes low when the reed switch is activated
    if ( not open ) {
        garage_status_string = GARAGE_OPEN;
    }

    //if both inputs are high, it means that the garage is moving
    // so if it was open, we believe it's closing now
    // and if it was closed, we believe it's opening now
    if ( open and closed ) {
        if ( previous_garage_status_string == GARAGE_OPEN ) {
            garage_status_string=GARAGE_CLOSING;
        }
        if ( previous_garage_status_string == GARAGE_CLOSED ) {
            garage_status_string=GARAGE_OPENING;
        }
    }
    
    //if status of the garage changed from last scan, publish the new status
    if ( previous_garage_status_string != garage_status_string ) {
        Particle.publish(PUSHBULLET_NOTIF, "Your garage door is " + garage_status_string, 60, PRIVATE);
    }

    return 0;
}

/*******************************************************************************
 * Function Name  : garage_stat  // function name cannot be longer than 12 chars otherwise it wont be registered!
 * Description    : reads and publishes the status of the garage, intended for using it with a service like ifttt or pushbullet
 * Return         : 0
 *******************************************************************************/
int garage_stat(String args)
{
    int opened = digitalRead(garage_OPEN);
    int closed = digitalRead(garage_CLOSE);

    if ( not closed ) {
        garage_status_string = GARAGE_CLOSED;
    }
    if ( not opened ) {
        garage_status_string = GARAGE_OPEN;
    }
    
   Particle.publish(PUSHBULLET_NOTIF, "Your garage door is " + garage_status_string, 60, PRIVATE);

    return 0;
}

      

Credits

Andrew Pena

Andrew Pena

1 project • 5 followers
While my profession is a sales leader, I’m fascinated by tech and find myself trying to learn and do as much as possible!

Comments