Lucas LarsonJordan TrakasFoster Hawkins
Published

IOT Home Security System with Particle Argon

Home Security at the touch of your fingers! Get notifications when your house door is opened.

BeginnerFull instructions provided2 hours665
IOT Home Security System with Particle Argon

Things used in this project

Hardware components

Argon
Particle Argon
×3
Breadboard (generic)
Breadboard (generic)
×3
Small Solderless Breadboard Kit
Digilent Small Solderless Breadboard Kit
×2
Jumper wires (generic)
Jumper wires (generic)
×1
USB Li Ion Battery Charger
Adafruit USB Li Ion Battery Charger
×3
Laser Transmitter
×1
Photo resistor
Photo resistor
×1
Buzzer
Buzzer
×3
LED (generic)
LED (generic)
×1
Resistor 220 ohm
Resistor 220 ohm
×1

Software apps and online services

Particle Build Web IDE
Particle Build Web IDE
Maker service
IFTTT Maker service
Google Sheets
Google Sheets

Story

Read more

Schematics

Argon 1 - Laser Emitter Fritzing Diagram

Argon 2 - Laser Receiver Fritzing Diagram

Argon 3 - Data Acquisition Fritzing Diagram

Code

Laser Emitting Argon

Arduino
Particle Web IDE
//LASER EMMITTING ARGON

int led= D7;
int laser = D0; //laser emmitter
int buzzer = D4; //active buzzer
int ledstate=LOW; //read led state


void setup() {
 
  pinMode(led, OUTPUT);
  pinMode(laser, OUTPUT);
  pinMode(buzzer, OUTPUT);
  Particle.subscribe("jtrakas1", brokendoorfunc, ALL_DEVICES); // function from J. Trakas Argon - Laser reciever
  Particle.subscribe("llarson4", itreallyisbrokenfunc, ALL_DEVICES); // communication back to J. rakas Argon
    
}


void loop(){
     
digitalWrite(laser, HIGH);

ledstate= digitalRead(D7);

if (ledstate == HIGH){
 
tone(buzzer, 2093, 650);
delay(500);
/*tone(buzzer, 5500, 650);
delay(75);*/

}
}   


int brokendoorfunc(const char *event, const char *data) //Read function from Argon 2
{
    if(strcmp(data, "Door Open")==0){
        digitalWrite(led, HIGH);
        Particle.publish("llarson4", "broken"); //Publish broken to signal Argon 2
      
    }
    else if (strcmp(data, "Door Closed")==0){
        digitalWrite(led, LOW);
        Particle.publish("llarson4", "intact");
    }
    else{
        
    }
}

int itreallyisbrokenfunc(const char *event, const char *data)
{
    if(strcmp(data, "broken")==0){
        
    }
    if(strcmp(data,"intact")==0){
        
    }
}

Laser Receiving Argon Circuit

Arduino
This is the code that was used for the laser receiving circuit. The language was Particle Web IDE
// This is the Code for the Laser Receiving Circuit
int phor = D0;
int ledwr = D9;
int  led = D7;
int buzz = D8;
int lastsensorreading = LOW;
int sensorreading = LOW;
int val;
int bing = D4; // The above section initializes which pins will be used in the Particle Argon

void setup() {
pinMode(ledwr, OUTPUT);
pinMode(led, OUTPUT);
pinMode(phor, INPUT_PULLUP);
pinMode(buzz, OUTPUT);
pinMode(bing, OUTPUT);
Particle.subscribe("llarson4", itreallyisbrokenfunc, ALL_DEVICES);
Particle.subscribe("jtrakas1",brokendoorfunc, ALL_DEVICES);
Particle.subscribe("fhawkins5", alarmonfunc, ALL_DEVICES);
              } // The void setup() section declares which pins will be used as inputs and outputs for the project as well as which events will be subscribed to. This allows Particle Communication


void loop() {
    lastsensorreading = sensorreading;
    sensorreading = digitalRead(phor);
    val = digitalRead(bing);    
    if (sensorreading == LOW && (lastsensorreading == HIGH)) {
        Particle.publish("jtrakas1", "Door Closed");
    }    
    if (sensorreading == HIGH && (lastsensorreading == LOW)) {
     Particle.publish("jtrakas1", "Door Open");
    }
    if (val == HIGH) {
    tone(buzz, 1568, 650);
        delay(500);
    }
    else {
        
    }
} // The void loop() section publishes an event every time a state switches (i.e. a door closes when it was previously open or opens when it was previously shut)

int brokendoorfunc(const char *event, const char *data)
{
    if (strcmp(data,"Door Open")==0){
      
    }
    else if (strcmp(data, "Door Closed")==0){
        
    }
    else{
        
    } // the brokendoorfunc function publishes data notifying whether the door used is open or closed
    
}    
int itreallyisbrokenfunc(const char *event, const char *data)
{
    if (strcmp(data,"broken")==0){
        digitalWrite(bing, HIGH);
    }
    else if (strcmp(data, "intact")==0){
        digitalWrite(bing, LOW);
    }
    else{
        
    }
} // the itreallyisbrokenfunc function writes the buzzer on or off depending on if a message is received from the transmission Argon

int alarmonfunc(const char *event, const char *data)
{
    if (strcmp(data,"Alarm On")==0){
        digitalWrite(led, HIGH);
    }
    else if (strcmp(data, "Alarm Off")==0){
        digitalWrite(led, LOW);
    }
    else{
        
    } // the alarmonfunc function writes an LED on or off depending on if a message is received from the data acquisition and cloud transmission Argon
    
}

Data Acquisition Argon

Arduino
Particle Web IDE
//Security system data acquisition code

//This device receives the signal that the door is open and activates a buzzer, turns on 
// an led, sends a signal back to the emitter device, and sends a signal to IFTTT to send the phone alert

//Define components
int led = D7;
int buzzer = D4;
int val;


//Setup components and define functions
void setup() {
    
  pinMode(led, OUTPUT);
  pinMode(buzzer, OUTPUT);
  Particle.subscribe("jtrakas1", brokendoorfunc, ALL_DEVICES);
  Particle.subscribe("fhawkinsifttt", fhawkinsiftttfunc);
  Particle.subscribe("fhawkins5", alarmonfunc, ALL_DEVICES);
  
}


//Loop checking the state of the led to determine if the buzzer should be on
void loop() {

   val = digitalRead(led);
   if(val == HIGH){
       tone(buzzer, 1047, 650);
       delay(500);
        }
            
     else{
         
       }
       
}


//Function to receive the state of the door
int brokendoorfunc(const char *event, const char *data)
    {
     
    if (strcmp(data, "Door Open") == 0){ //If door is open, then turn led on and send signal to IFTTT and send signal to turn alarm on
         digitalWrite(led, HIGH);
         Particle.publish("fhawkinsifttt", "alarm");
         Particle.publish("fhawkins5", "1"); //This command goes to IFTTT and compiles data into a Google sheet to create a graph 
    
    }
     
    else if (strcmp(data, "Door Closed") == 0){ //If door is closed turn led off and send signals to turn alarm off 
         digitalWrite(led, LOW);
         Particle.publish("fhawkinsifttt", "safe");
         Particle.publish("fhawkins5", "Alarm Off");
    }
     
    else{ //If it does not receive one of the previous commands, then do nothing
        
    }
    
}


int fhawkinsiftttfunc(const char *event, const char *data)
    {
    //IFTTT function does not need anything here in order to function
    }


int alarmonfunc(const char *event, const char *data)
    {
        
     if (strcmp(data, "Alarm On") == 0){ //Alarm function does need something inside here to work because it is communicating to other Particle devices
     
    }
     
     else if (strcmp(data, "Alarm Off") == 0){
        
     }
     
    else{
        
    }
    
}

Credits

Lucas Larson

Lucas Larson

1 project • 2 followers
Jordan Trakas

Jordan Trakas

1 project • 2 followers
Foster Hawkins

Foster Hawkins

1 project • 1 follower

Comments

Add projectSign up / Login