AJ AyersJohn FridayChase Largent
Published

Open Garage Door Alert System

This system is designed to notify the user if they have left their home with the garage door open.

BeginnerFull instructions provided8 hours291
Open Garage Door Alert System

Things used in this project

Hardware components

Argon
Particle Argon
×3
PIR Sensor, 7 m
PIR Sensor, 7 m
×1
RFID Module (Generic)
×1
Elegoo Digital Button
×1
Solderless Breadboard Half Size
Solderless Breadboard Half Size
×3
Jumper wires (generic)
Jumper wires (generic)
×1
Resistor 10k ohm
Resistor 10k ohm
×2

Software apps and online services

Particle Build Web IDE
Particle Build Web IDE
adafruit

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)

Story

Read more

Custom parts and enclosures

Motion Sensor Housing

STL file of the motion sensor housing used in this project.

Button Depressor Frame

STL file of the frame for the digital button that fits in the garage door track.

Button Depressor Spring

STL file for the spring used to depress the digital button.

Schematics

Digital Button Wiring Schematic

This schematic shows the wiring setup for the Digital Button.

Motion Sensor Wiring Schematic

This schematic shows the wiring setup for the Motion Sensor.

Laser Break Wiring Schematic

This schematic shows the wiring setup for the Laser Break.

Code

Button Switch/Notification

C/C++
int inputPin = D5;
int buttonSensor = HIGH; //initial unpressed value
int motionval = 1; //initial motion state
int keysval = 1; //initial keys state
int dooropen = 0; //initial door state

void setup(){
    Particle.subscribe("Motchar", motionFunction); //Subscribe to argon with motion sensor character output
    Particle.subscribe("Keychar", keysFunction); //Subscribe to argon with laser/photo sensor character output
    pinMode(inputPin, INPUT); //button switch input
    
}

void loop()
{
    delay(2000); //delays in this loop add to 10 seconds to satisfy adafruit publishing limit
    buttonSensor = digitalRead(inputPin); //reads input value from sensor
    
    if (buttonSensor == LOW) //checks for pressed button, the 1st condition
    {
        dooropen = 1;
        Particle.publish("Switch", String(dooropen)); //used to plot status on adafruit
        delay(1000);
        Particle.publish("Swichar", "OPEN"); //used to trigger other argons
    }
    else if (buttonSensor == HIGH) //otherwise checks for unpressed button
    {
        dooropen = 0;
        Particle.publish("Switch", String(dooropen)); //adafruit
        delay(1000);
        Particle.publish("Swichar", "CLOSED"); //other argons
    }
    else //should be either pressed or unpressed, but just in case
    {
    delay(1000);
    }
    delay(7000);
    
    if ((buttonSensor == LOW) && (motionval == 0) && (keysval == 0)) //checks that door is open, and no motion or keys detected
        {
            // Get some data
        String data = String(10);
            // Trigger the integration
        Particle.publish("GarageDoor", data, PRIVATE);
             // Wait 60 seconds
        //delay(60000);
        }
    else
    {
        
    }
    
}

void motionFunction(const char *event, const char *data) //if Motion_char publish is detected, motionFunction checks status
{
    if (strcmp(data,"Motion_No")==0)
    {
        motionval = 0; //changes value if there is no motion, 2nd condition
    }
    else
    {
        motionval = 1; //returns values to original status to avoid false positives
    }
}

void keysFunction( const char *event, const char *data) //if Keys_char publish is detected, keysFunction checks status
{
    if (strcmp(data,"Keys_No")==0)
    {
        keysval = 0; //changes value if there are no keys detected, 3rd condition
    }
    else
    {
        keysval = 1; //returns values to original status to avoid false positives
    }
}

PIR Motion Sensor

C/C++
int inputPin = D5;
int motionSensor = LOW; //initial sensor value for no motion
int motionval = 0; //initial motion state

void setup(){
    Particle.subscribe("Swichar", motionFunction); //Subscribe to argon with button switch character output
    pinMode(inputPin, INPUT); //PIR motion sensor input
}

void loop()
{
    motionSensor = digitalRead(inputPin); //reads input value from sensor
    if (motionSensor == LOW)
    {
        motionval = 1; //positive motion state
    }
    else if (motionSensor == HIGH)
    {
        motionval = 0; //negative motion state
    }
    else
    {
        
    }
}

void motionFunction(const char *event, const char *data) //triggered by Switch_char event
{
    if (strcmp(data, "OPEN")==0) //checks door status, open indicates need to publish motion status
    {
    
        if (motionval == 1) //indicates motion currently detected
        {
            Particle.publish("Motchar", "Motion_Yes"); //used by switch argon
        }
        else if (motionval == 0) //indicates no motion currently detected
        {
            Particle.publish("Motchar", "Motion_No"); //used by switch argon
        }
        else
        {
            
        }
        
        delay(1000);
        Particle.publish("Motion", String(motionval)); //publishes 0/1 used for plotting on adafruit
    }
    else
    {
        
    }
}

Photo Resistor/Laser Emitter

C/C++
int laserPin = D0; //digital output
int photoPin = A0; //analog input
int photoval = 10000;
int keys = 0; //initial keys state

void setup()
{
    Particle.subscribe("Swichar", keyFunction); //subscribes to argon with button switch
    pinMode(laserPin, OUTPUT); //Laser Emitter Output
    pinMode(photoPin, INPUT); //Photo Resistor Input
    digitalWrite(laserPin, HIGH); //sets laser to high output value
}
    
void keyFunction(const char *event, const char *data) //triggered by Switch_char event
{
    if (strcmp(data, "OPEN")==0) //checks door status, open indicates need to publish keys status
    {
        
        photoval = analogRead(photoPin); //reads input value from sensor
        
        if (photoval>=800) //broken beam creates reading above 800 (ambient light), keys are present
        {
            Particle.publish("Keychar", "Keys_Yes"); //used by switch argon
            keys = 1; //used for charting on adafruit
        }
        
        else if (photoval<800) //unbroken laser beam creates reading below 800, keys missing
        {
            Particle.publish("Keychar", "Keys_No"); //used by switch argon
            keys = 0; //used for charting on adafruit
        }
        
        else
        {
        
        }
        
        Particle.publish("Keys", String(keys)); //triggers adafruit to update chart
        
    }   
}

Credits

AJ Ayers

AJ Ayers

1 project • 1 follower
John Friday

John Friday

1 project • 1 follower
Chase Largent

Chase Largent

1 project • 1 follower

Comments