Hackster is hosting Hackster Holidays, Finale: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Tuesday!Stream Hackster Holidays, Finale on Tuesday!
Paul Elsberg
Published © LGPL

Internet Controlled Garage Door

Control and query your garage door with IFTTT.

IntermediateWork in progress1,300
Internet Controlled Garage Door

Things used in this project

Hardware components

General Purpose Transistor PNP
General Purpose Transistor PNP
×1
Resistor 330 ohm
Resistor 330 ohm
×1
Jumper wires (generic)
Jumper wires (generic)
×1
force sensor
×1
Resistor 1k ohm
Resistor 1k ohm
×1
Spark Core
Particle Spark Core
×1

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
multimeter

Story

Read more

Schematics

Fritzing Diagram

Basic outline of circuit excluding connections to garage button

Connection to garage door

Use a multimeter to find what changes when you hit the button then attach the necessary jumpers to said location. In my case hitting the button sent a ground signal to tell the door to close thus why I used a transistor to control the ground current. I also chose to power the opener with the photon so I connected the 3.3v and ground to the pins where the coin cell battery was connected.

Code

Garage Door Photon Build

Arduino
Copy code into the Particle Web IDE
/**Control and Query The Garage Door
    By Paul Elsberg
    
    
    Hardware
    
    Button:
    Connect the Garage door power to the VIN IF you want to power the photon from the coin cell battery on the charger!!! 
    Connect Garage Door ground to Photon ground
    Find and connect a signal generated by pressing the opener button to center bottom C of a PNP transistor (my button push signal was - )
                                                     |                                  ^
                                                     v                                  |
    Connect the ground to the top of the transistor C                                                                                    
    connect D0 to the center pin of the transistor to use a HIGH signal to trigger the flow of current and a LOW signal to stop it 
    
    
    Force Sensor:
    Connect 3.3v to 1kohm to one pin of force sensor
    Connect A0 on to the resistor (force pin side)
    Connect ground to other pin of force sensor
    link to visual
    https://community.particle.io/t/coffee-break-anybody-with-maker-kit-publish/4091?redirected=true
    
    **/


//declar variables 
int force = 0;
int button = D0;

void setup() {
//Sensing Force
pinMode(A0,INPUT);
//controlling opener
pinMode(button,OUTPUT);

Particle.variable("force",&force,INT);
//find out the state of the door
Particle.function("garageStatus",garageStatus);
//tell the door to close or open
Particle.function("garageButton",garageButton);
Serial.begin(9600);
}


void loop() {
}
//measures state using force threshhold
int garageStatus(String command){
    //read force of door
    force = (int)analogRead(A0);
    //adjust threshhold to your setup
    if(force > 400){
        //the garageStatus event provides various data based on the state
        Particle.publish("garageStatus","closed");
        //returning an integer allows other particle functions to easily communicate
        return 1;
    }
    else{
        Particle.publish("garageStatus","open");
        return 0;
    }
    
}
//tell the garage whether to close or open 
int garageButton(String command){
    //accept both to account for automatic uppercase when starting a text 
    if ((command =="close")||(command=="Close")){
        //make sure that the door is open
        if(garageStatus("")==0){
            //hit the garage button
            digitalWrite(button,HIGH);
            delay(200);
            digitalWrite(button,LOW);
            //wait the time it takes for YOUR garage to close
            delay(5000);
            //ensure the garage did actually close
            if(garageStatus("")==1)
            {
                Particle.publish("garageStatus","successClose");
                //sucess
                return 1;
            }
            //either the force sensor is not contacted by the door or something is in the way
            else{
                Particle.publish("garageStatus","notWorking");
                //failure
                return 0;
            }
        }
        //the door doesn't need to be closed
        else{
            Particle.publish("garageStatus","alreadyClose");
            //desired state achieved
            return 1;
        }
    }
    //similar structure to open the door
    else if ((command =="open")||(command=="Open")){
        //if the door's closed
        if(garageStatus("")==1){
            //hit the garage door button
            digitalWrite(button,HIGH);
            delay(200);
            digitalWrite(button,LOW);
            //wait the time it takes for YOUR garage door to open
            delay(5000);
            //make sure it opened
            if(garageStatus("")==0)
            {
                Particle.publish("garageStatus","successOpen");
                //success
                return 1;
            }
            //button's not working 
            else{
                Particle.publish("garageStatus","notWorking");
                //failure
                return 0;
            }
        }
        //the door doesn't need to be opened
        else{
            Particle.publish("garageStatus","alreadyOpen");
            //desired state achieved
            return 1;
        }
    }
    //not a valid command
    else{
        return 0;
    }
}

Credits

Paul Elsberg
4 projects • 19 followers

Comments