Claire KrawczykMargeory Castellanos
Published © GPL3+

Front Door Security Alarm

Can't afford an expensive security system, but still want to protect your home? This simple alarm is all you need to scare off any intruder!

EasyWork in progress10 hours668
Front Door Security Alarm

Things used in this project

Hardware components

Photon
Particle Photon
×2
PIR Motion Sensor (generic)
PIR Motion Sensor (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×5
Piezo Sensor
ControlEverything.com Piezo Sensor
×1
Breadboard (generic)
Breadboard (generic)
×2

Software apps and online services

ThingSpeak API
ThingSpeak API
Google Sheets
Google Sheets
Maker service
IFTTT Maker service

Story

Read more

Schematics

PID Sensor Schematic

This is the schematic for how the PID sensor breadboard was setup to connect to the Photon.
Pid schematic hvkn9xoopm

Alarm Schematic

This is the schematic for the alarm. It shows how the alarm is connected on the breadboard to the Photon.
Alarm schematic cmt89a1fl8

Code

Tripwire Code

C/C++
This was the code used to read motion detected by the PIR sensor and publish the signal.
//Code for PIR sensor
int led = D7;       
int tripwire_input = D0;                           
int pirState = LOW;             
int val = 0;                    
#define publish_delay 16000
unsigned int lastPublish = 0;

int calibrateTime = 5000;      

void setup() {
    
    pinMode(led, OUTPUT);
    
    pinMode(tripwire_input, INPUT);
}

void loop() {
    
  if (calibrated()) {
      
    readTheSensor();

    reportTheData();
    }
}

void readTheSensor() {
    val = digitalRead(tripwire_input);
}

bool calibrated() {
    return millis() - calibrateTime > 0;
}

void setLED(int state) {
    digitalWrite(led, state);
}

void reportTheData() {
    
    if (val == HIGH) {
        
        if (pirState == LOW) {
            int value = 1;
          
          Particle.publish("ALERT!", "Someone is Approaching", 60);
          Particle.publish("thingSpeakWrite_D0", "{ \"1\": \"" + String(value) + "\", \"k\": \"NNXNV81JDXLW6J6E\"}", 60, PRIVATE);
         
          pirState = HIGH;
          setLED(pirState);
        }
    } else {
        if (pirState == HIGH) {
          
          Particle.publish("ALERT!", "Off", PRIVATE);
          pirState = LOW;
          setLED(pirState);
        }
    }
}

Alarm Code

C/C++
This is the code used to trigger the alarm when the motion sensor has been tripped.
// This #include statement was automatically added by the Particle IDE.
#include <ThingSpeak.h>

int led = D7;

void setup() {
    
    pinMode(led, OUTPUT);

    Particle.subscribe("ALERT!", turnon);

}

void turnon(const char *event, const char *data) {
    
    if(strcmp(event, "ALERT!")==0){
        
        digitalWrite(led, HIGH);
        
        delay(5000);
        
        digitalWrite(led, LOW);
        
    }

}

Credits

Claire Krawczyk

Claire Krawczyk

1 project • 1 follower
Margeory Castellanos

Margeory Castellanos

0 projects • 0 followers

Comments

Add projectSign up / Login