DIY Arduino PIR Motion Sensor Lighting & Security
From the minds at http://arduinotronics.blogspot.com/

We wanted to save energy, and create convenience, by adding motion sensors to our lighting circuits. Maybe you want some notification of an intruder. Both can be done with a PIR Motion sensor. When I walk into a room, the lights come on automatically, and when I leave, shut off after a short period of time. You can choose how long that time delay is in the code. No more fumbling for a light switch in the dark with my arms full of groceries!

I also wanted a override switch for times I want the light to stay on, or off.

So, I took an Arduino, added a PIR sensor, a SSR, a SPDT switch, two 10k ohm resistors and whipped up a small sketch to glue it all together. Enjoy!

Original article, and more at http://arduinotronics.blogspot.com/2013/01/motion-sensors-ssrs.html

Multiple motion sensors, and multiple SSR's can be serviced by a single Arduino. A embedded Atmel chip can be built into the project instead of dedicating a complete Arduino board.

A CdS light sensor can be added to prevent the lights from activating if light level's are considered sufficient (user programmable). http://arduinotronics.blogspot.com/2012/03/light-sensing-with-cds-ldr.html

Step 1: The PIR Sensor

DIY Arduino PIR Motion Sensor Lighting & Security
The first step was connecting a PIR sensor. A PIR detects "motion" by recognizing an increase in Infra Red emission in the focus area, put out by the human body.

For background info on PIR, see http://en.wikipedia.org/wiki/Passive_infrared_sensor

We obtained our PIR Sensor from Amazon.

Connect the 3 pins of the PIR to +5vdc, Arduino Pin 2 (data out), and Ground.

Step 2: SSR

DIY Arduino PIR Motion Sensor Lighting & Security
A SSR is a solid state relay. It consists of a photo transistor and a triac, along with supporting circuitry. This isolates the 120vac load from the Arduino, so no damage from the high voltage AC can happen.

For background info on SSR's see http://en.wikipedia.org/wiki/Solid_state_relay

We obtained our SSR from Amazon.

Connect Screw Terminal 4 to Ground, Screw Terminal 3 to Arduino Pin 13, and Screw terminals 1 & 2 insert in Series (this is important) with the HOT wire going to your appliance (make sure your cord is unplugged or breaker is off if hardwiring).

Step 3: Manual Control Switch

DIY Arduino PIR Motion Sensor Lighting & Security
We wanted a way to override the PIR, and offer a Automatic (PIR), Manual ON, and Manual OFF mode. We added a SPDT Switch, with center off, and connected the center pin to +5vdc, and the two outer pins to Arduino pins 11 & 12. The two outer pins also have a 10k ohm resistor (each) to Ground.

Radio Shack carries a 5 pack of resistors for $1.20 or so.

We obtained the SPDT w/ Center Off switch from Amazon.

For more info on SPDT and other types of switches, see http://en.wikipedia.org/wiki/Single_pole,_double_throw#Contact_terminology


Step 4: The Arduino Code

DIY Arduino PIR Motion Sensor Lighting & Security
The code that makes this all happen is as follows:


int inPin1 = 11; // switch connected to digital pin 11
int inPin2 = 12; // switch connected to digital pin 12

int ssrPin = 13;
int pirPin = 2;
int motionDetect= 0;
int manualSwitch = 0;
int motionSwitch = 0;

void setup() {
pinMode(ssrPin, OUTPUT);
pinMode(pirPin, INPUT);
pinMode(inPin1, INPUT);
pinMode(inPin2, INPUT);
digitalWrite(ssrPin, LOW);
}

void loop() {

motionSwitch = digitalRead (inPin1);
manualSwitch = digitalRead (inPin2);

if (motionSwitch == HIGH) // Motion Mode
{
motionDetect = digitalRead(pirPin);
if (motionDetect == HIGH)
{
digitalWrite(ssrPin, HIGH);
delay (180000); //Optional 3 minute delayed off
digitalWrite(ssrPin, LOW);
}
}
else if (manualSwitch == HIGH) // Manual On
{
digitalWrite(ssrPin, HIGH);
}
else // Manual Off

{
digitalWrite(ssrPin, LOW);
}
}

Step 5: The Schematic

DIY Arduino PIR Motion Sensor Lighting & Security
Here is the schematic that shows all the wiring:


Step 6: Using a Light Sensor (LDR/CdS)

DIY Arduino PIR Motion Sensor Lighting & Security
One option is to prevent the lights from coming on if the ambient light levels are over a certain amount. This is the typical operation of an outdoor motion sensor. If the sun is up, the lights do not come on. This CdS tutorial will get you started on adding that option. If the reading is over a certain amount, inhibit the light on function.

http://arduinotronics.blogspot.com/2012/03/light-sensing-with-cds-ldr.html
 
 

Tag cloud

make build easy simple arduino making homemade solar laser printed portable cheap mini building custom cardboard wooden create super lego turn paracord chocolate your paper light intel