Evan KlickGrayson BarcinasBraeden Bluitt
Published

IOT Project - Door Gap Sensor

This project utilized an argon particle detector as well as several sensors to detect whether or not a door is open or closed.

IntermediateFull instructions providedOver 1 day77
IOT Project - Door Gap Sensor

Things used in this project

Hardware components

Argon
Particle Argon
×3
Solderless Breadboard Half Size
Solderless Breadboard Half Size
×3
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×2
Male/Male Jumper Wires
×11
Resistor 330 ohm
Resistor 330 ohm
×4
LED (generic)
LED (generic)
×1
Buzzer
Buzzer
×1
Pushbutton switch 12mm
SparkFun Pushbutton switch 12mm
×1
Through Hole Resistor, 470 ohm
Through Hole Resistor, 470 ohm
×1

Software apps and online services

Arduino IDE
Arduino IDE
Maker service
IFTTT Maker service
Google Sheets
Google Sheets

Story

Read more

Schematics

Schematics

Code

Ultrasonic Sensor Code

C/C++
// This #include statement was automatically added by the Particle IDE.
#include "HC-SR04.h"

// This #include statement was automatically added by the Particle IDE.
#include <HC-SR04.h>




double cm = 0.0;
bool beam_status = false;

int trigPin = D4;
int echoPin = D5;

HC_SR04 rangefinder = HC_SR04(trigPin, echoPin);
void setup(){

    Spark.variable("cm", &cm, DOUBLE);
    pinMode(trigPin, OUTPUT);
    pinMode(echoPin, INPUT_PULLUP);
}

void loop() 
{
     cm = rangefinder.distCM();
    if (cm<40){
        if (beam_status==false){
        
            Particle.publish("Breach",String(cm));
            beam_status = true;   
        }
    } else {
        if (beam_status==false){
            
        } else {
            Particle.publish("Clear","Clear");
            beam_status = false;
        }
    }
    delay(1050);

   
    
    
}

LED & Buzzer Code

C/C++
void setup() 
  

//buzzers for front and rear sensors
{
    pinMode(D7,OUTPUT);
    Particle.subscribe("Clear",highfunc,MY_DEVICES);
    Particle.subscribe("Breach",lowfunc,MY_DEVICES);
   pinMode(D6,OUTPUT);
}


void highfunc(const char *event, const char *data)
{
    tone(D7,0,0); //buzzer silent
    digitalWrite(D6,LOW);
}

void lowfunc(const char *event, const char *data)
{
    tone(D7,3500,2000); //buzzer making noise

 digitalWrite(D6,HIGH); // led lights for front and rear sensors
 



    
    
}

Button Code

C/C++
int pushButton = D5; 


void setup() 
{
  pinMode(pushButton, INPUT_PULLUP); 
  
}


void loop() 
{
  int pushButtonState; 

  pushButtonState = digitalRead(pushButton);

  if(pushButtonState == LOW)
  { 
     
    Particle.publish("Button","Pressed",60,PRIVATE);
  
    delay(5000); 
  }

}

Credits

Evan Klick

Evan Klick

1 project • 1 follower
Grayson Barcinas

Grayson Barcinas

1 project • 1 follower
Braeden Bluitt

Braeden Bluitt

1 project • 1 follower
Thanks to Braeden Bluitt and Grayson Barcinas .

Comments

Add projectSign up / Login