Taylor BradyEzequiel Oruez
Published

MEGR 3171 Security Alarm

This project is a security system that will alert your cell phone when the PIR sensor is tripped.

IntermediateFull instructions provided3 hours188
MEGR 3171 Security Alarm

Things used in this project

Hardware components

5 mm LED: Yellow
5 mm LED: Yellow
×1
Jumper wires (generic)
Jumper wires (generic)
×14
Grove - PIR Motion Sensor
Seeed Grove - PIR Motion Sensor
×1
Photon
Particle Photon
×2
Buzzer, Piezo
Buzzer, Piezo
×1
Portable charger
×1

Software apps and online services

Particle Build Web IDE
Particle Build Web IDE
ThingSpeak API
ThingSpeak API
Maker service
IFTTT Maker service
Google Sheets
Google Sheets
Fritzing

Hand tools and fabrication machines

Wire Stripper & Cutter, 18-10 AWG / 0.75-4mm² Capacity Wires
Wire Stripper & Cutter, 18-10 AWG / 0.75-4mm² Capacity Wires

Story

Read more

Schematics

PIR sensor

Photon Receiver

Code

Photon2 LED/Buzzer reciever

C/C++
The second photon was used to respond to the output signal produced by the first photons' IR sensor. The code allowed us to sequence a alarm to be triggered when the response was anything lager than 0 (stable). Once the alarm was triggered the circuit integrated into the photon turned on a bright yellow LED light along with a passive buzzer to signal that an intruder has entered.
// Buzzer/LED alarm

//parameters
int inPin = D0;              
int ledPin = D7;                
int pIRstate = LOW;             
int val = 0;                    

int ResetTime = 8000;      
//led signal config
void setup()
{
  pinMode( ledPin, OUTPUT );
  pinMode(inPin, INPUT);     
}
//sensor feedback config
void loop()
{

 
  if ( calibrated() )
  {
    readTheSensor();
    
    reportTheData();
  }
}

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

bool calibrated() {
  return response() - ResetTime > 0;
}

void reportTheData() {

  
  if (val == HIGH) {

    if (pIRstate == LOW) {
     
      Particle.publish("ezeIR", "1");
      
      pIRstate = HIGH;
      setLED( pIRstate );
    }
  } else {
    if (pIRstate == HIGH) {
     
      pIRstate = LOW;
      setLED( pIRstate );
    }
  }
}

//end
 void setLED( int state )
{
  digitalWrite( ledPin, state );
}

Photon1 IR-sensor

C/C++
This code was used to configure a SeeedGrove PIR sensor The code allows us to detect any breach in the IR (120 degree) frame and report it as its respective binary value. (1=intruder_detected, 0=Steady)
// Photon1-PIR_Motion sensor


//parameters
int inPin = D0;              
int ledPin = D7;                
int pIRstate = LOW;             
int val = 0; 
int ezeIR =1;
int led = D7;

//photon LED config
int calibrateTime = 5000;      

void setup()
{
  pinMode( ledPin, OUTPUT );
  pinMode(inPin, INPUT);
  Particle.subscribe("Recieved", Recieve, "2d002d000947373034353237");
}
void Recieve(const char *event, const char *data)
{
  digitalWrite(led, HIGH);
  delay(1000);
  digitalWrite(led, LOW);
  delay(1000);
  digitalWrite(led, HIGH);
  delay(1000);
  digitalWrite(led, LOW);
  delay(1000);
  digitalWrite(led, HIGH);
  delay(1000);
  digitalWrite(led, LOW);
}
void loop()
{
//Sensor breach parameters
  
  
  if ( calibrated() )
  {

    readTheSensor();

   
    reportTheData();
  }
}

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

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

void reportTheData() {

  
  if (val == HIGH) {

   ezeIR= ezeIR;
   Particle.publish("Intruder_Alert", String(ezeIR));
   delay(10000);
   }
   else if (pIRstate == LOW) {
     ezeIR = 0;
    }
}
//end
void setLED( int state )
{
  digitalWrite( ledPin, state );
}

Credits

Taylor Brady

Taylor Brady

1 project • 0 followers
Ezequiel Oruez

Ezequiel Oruez

1 project • 0 followers

Comments

Add projectSign up / Login