Parker SchmidTravis DixonThomas Cody
Published

Home Security Motion Sensor

Home security alert system which remotely detects motion at your door and notifies you when someone enters your home!

BeginnerWork in progress6 hours69
Home Security Motion Sensor

Things used in this project

Hardware components

Argon
Particle Argon
×3
Grove - PIR Motion Sensor
Seeed Grove - PIR Motion Sensor
×1
High Brightness LED, White
High Brightness LED, White
×3
Jumper wires (generic)
Jumper wires (generic)
×7
Male/Female Jumper Wires
×3
Solderless Breadboard Half Size
Solderless Breadboard Half Size
×3
USB-A to Micro-USB Cable
USB-A to Micro-USB Cable
Wall adaptors included.
×3

Software apps and online services

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

Story

Read more

Schematics

Motion Sensor Module

Indicator Module

PIR Motion Sensor

Indicator 1

Indicator 2

Code

Argon LED Indicator

C/C++
This is the code used to allow the Argon to use an LED to indicate when the motion detector has detected motion.
//LED ARGON 1 (TRAVIS)
int led = D7;
int state = 0;
int Good_Recieve = 1;



void setup() {

pinMode(led, OUTPUT);
//digitalWrite(led, LOW);

Particle.subscribe("Motion_alert", myHandler, "e00fce682e9728551f3c44ac");


}

void myHandler(const char *Motion_Alert, const char *myHandler)
{
Particle.publish("Recieved", String(Good_Recieve));
  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() {

}

Motion Detector

C/C++
This is the code that takes a signal from the motion detector and causes the Argon to send a signal to the LED indicator to blink,
//Motion sensor
int inputPin = D0;              
int ledPin = D7;                
int pirState = LOW;             
int val = 0; 
int myHandler =1;
int led = D7;


int calibrateTime = 5000;      

void setup()
{
  pinMode( ledPin, OUTPUT );
  pinMode(inputPin, INPUT);
  Particle.subscribe("Recieved", Good_Recieve, "E00FCE685C596CC5CD3975CB");
  Particle.subscribe("Recieved", Good_Recieve, "e00fce68144a467e5d29be7a");
}
void Good_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()
{

  
  if ( calibrated() )
  {

    readTheSensor();

   
    reportTheData();
  }
}

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

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

void reportTheData() {

  
  if (val == HIGH) {

   myHandler= myHandler;
   Particle.publish("Motion_alert", String(myHandler));
   delay(10000);
   }
   else if (pirState == LOW) {
     myHandler = 0;
    }
}

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

Credits

Parker Schmid

Parker Schmid

1 project • 0 followers
Travis Dixon

Travis Dixon

1 project • 0 followers
Thomas Cody

Thomas Cody

1 project • 0 followers

Comments

Add projectSign up / Login