Home Security
Made by Swati Rajendran
Made by Swati Rajendran
A simple device that alerts you if there is an intruder in your home!
Created: January 29th, 2016
Particle Photon
LED (red) : Motion Indication
LED (blue) : ON/OFF Indication
2 Resistors 1k ohms
Jumper wires
I decided to use a Motion Sensor to build the device. I began working on a basic circuit with just the PIRsensor. I then decided to incorporate a switch to disable the device manually, to avoid unnecessary alerts when we were at home. I also added an indicator LED that light up when the device was activated. The next thing was to connect it to the cloud. Once I checked the data on the Serial monitor was correct, I connected the 'event' captured on the device to IFTTT so that it gave sent me a notification (e-mail alert in this case) on my phone.
The system would be switched ON just before we left home, and switched OFF when we were back home.
Once the device is switched ON, and the PIR Sensor senses any movement and sends us notification.
The code used is a slightly modified version of a code provided in the PIR sensor guide by Adafruit. https://learn.adafruit.com/pir-passive-infrared-proximity-motion-sensor/how-pirs-work
/*
* PIR sensor tester
*/
int ledPin = D0; // choose the pin for the LED
int inputPin = D1; // choose the input pin (for PIR sensor)
int pirState = LOW; // assuming no motion detected
int val = 0; // variable for reading the pin status
void setup() {
pinMode(ledPin, OUTPUT); // declare LED as output
pinMode(inputPin, INPUT); // declare sensor as input
Serial.begin(9600);
}
void loop()
{
val = digitalRead(inputPin); // read input value
digitalWrite(ledPin, HIGH); // turn LED ON
Serial.println(val);
if (val == HIGH)
{ // check if the input is HIGH
if (pirState == LOW)
{
// we have just turned on
Serial.println("Motion detected!");
Particle.publish ("motion-detector","motion detected! Intruder!", PRIVATE);
// We only want to print on the output change, not state
pirState = HIGH;
}
}
else {
if (pirState == HIGH)
{
pirState = LOW;
}
}
digitalWrite(ledPin, pirState ); // turn LED OFF
}
Click to Expand
Being my very first experience with embedded circuits and related programming, and introduction to connected systems in general, this was a very engaging first project. I spent a substantial amount of time warming up to the project; spent most of class time trying out various sensors. It was exciting! But as I tweaked around with various components, the coding soon got quite challenging for me as a beginner. I did require a lot of help from Steffen, some of my proficient classmates and friends while trying to keep up with the iterative and rather frustrating process of coding and debugging and rewriting.
I am however excited about working on more creative projects as I get better with the programming and circuitry!
This course charts the emergence of the now "connected world" to explore the possibilities for future products and connected spaces.
A simple device that alerts you if there is an intruder in your home!