My parents recently purchased a new house and are concerned about intruders. In order to help catch people from stealing everything I created a motion sensor that will send me an email when triggered.
ElectronicsThe electronics in this project are pretty simple. I started by attaching a PIR motion sensor to a Particle Argon. Here is the first iteration of the electronics portion of the project:
I then decided to add an LED so that I could tell when the motion sensor was triggered:
Here is a top down image of the final electronics:
My PIR Sensor had physical settings and they can be set with the dials and the pins shown below.
The dial on the left in the first image is to control the time it takes between senses. I set that to the minimum of 3 seconds in order to receive as much data as possible.
The dial on the right in the first image is to control the Sensitivity. I set it to the maximum of 7 meters in order to sense as much of the room as possible.
The pins in the second image decide weather or not the trigger can be triggered multiple times a second or have it set by the dial, which can be set to once every 3-300 seconds. I set it to be overridden by the dial.
CodeAll of the code below is written in C. I started by setting up the initial variables and defined the pin numbers:
int ledPin = 3; //LED pin
int sensorPin = 5; //Sensor pin
int tempSensorInput = 0; //This reads the motion status
I then set up the setup class:
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(sensorPin, INPUT);
}
I then set up the loop class to check if the Motion Detector has detected anything. If it has, it will publish an event in order to trigger IFTTT and turn on the LED for 5 seconds.
void loop(){
tempSensorInput = digitalRead(sensorPin); //reads the input value
if (tempSensorInput == HIGH) //checks to see if their is an input. If there is: the led turns on, the argon publishes an event to trigger IFTTT, waits 5 seconds, and finally turns the LED off.
{
digitalWrite(ledPin, HIGH);
Particle.publish("IntruderAlert", "Uh oh");
delay(5000);
digitalWrite(ledPin, LOW);
}
}
This is what the final code looks like:
int ledPin = 3; // LED pin
int sensorPin = 5; // Sensor pin
int tempSensorInput = 0; // ths reads the motion status
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(sensorPin, INPUT);
}
void loop(){
tempSensorInput = digitalRead(sensorPin); //reads the input value
if (tempSensorInput == HIGH) //checks to see if their is an input. If there is: the led turns on, the argon publishes an event to trigger IFTTT, waits 5 seconds, and finally turns the LED off.
{
digitalWrite(ledPin, HIGH);
Particle.publish("IntruderAlert", "Uh oh");
delay(5000);
digitalWrite(ledPin, LOW);
}
}
IFTTTNext I used IFTTT to connect the Particle Argon to my Email address. I made it so that every time the motion sensor detects anything it will send me an email. I started by selecting the "if" trigger:
And then decided what should happen if that is triggered:
I then know that it works when I receive this email at my personal email address:
Comments
Please log in or sign up to comment.