loading
Picture of 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

Picture of The PIR Sensor
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.
 
1-40 of 53Next »
HaripriyaR1 month ago

I have used 220V ac instead of 120V ac. The LED burnt out each time I turned on the voltage. Can you tell me why this is happening? Can I build the circuit without an SSR?

The specification olf the SSR i used is: 40VA

24~380VAC across pins 1&2

500Kohm/0.25W across pins 3&4

sspence (author)  HaripriyaR1 month ago
Why are you using a 500k across pins 3 & 4? Those pins are for direct 5v control from the Arduino.

Since you are using 220vac on the primary side, You have to use 220vac lights. Yes, you have to use a SSR because an arduino is 5vdc only, and would fail spectacularly at 220vac. You could use a arduino relay board instead of the ssr.
grace wambui2 months ago

how do i use embedded atmel chip

sspence (author)  grace wambui2 months ago
See http://www.instructables.com/id/The-Embedded-Arduino-building-an-Arduino-into-a-p/
grace wambui2 months ago

how do i use embedded atmel chip

sspence (author)  grace wambui2 months ago
see http://www.instructables.com/id/The-Embedded-Arduino-building-an-Arduino-into-a-p/
grace wambui2 months ago

how will connect atmel chip if i dont use arduino

myl1236 months ago
Sir, I'm about to use your creative work as my project. I just wanted to ask, we already have the PIR sensor, what's the use of the LDR??
sspence (author)  myl1235 months ago
The LDR deactivates the lights during daylight hours in a security lighting application. The lights only come on from dusk to dawn.
monloi.perez5 months ago
Hi, are you selling this or any place that I can buy this?
sspence (author)  monloi.perez5 months ago
I'm not selling it, but there are parts links in the instructable.
myl1236 months ago
Sir, I'm about to use your creative work as my project. I just wanted to ask, we already have the PIR sensor, what's the use of the LDR??
myl1236 months ago
Sir, I'm about to use your creative work as my project. I just wanted to ask, we already have the PIR sensor, what's the use of the LDR??

Thanks! I understand now how it all works. This is great! I just have one more question though. Can the arduino take 4 motion sensors (like the ones in this tutorial) and 4 SSr's relays? my concern is the 5v, if it will be OK to handle all that. I think I could use just the two switches to control on/off the whole thing....

sspence (author)  Hermes.Mauricio.Duarte7 months ago
there's no problem supporting 4 motion sensors and 4 ssr's. The ssr's are just a LED connected to the Arduino.

Stupid but quick question. The diagram shows two +5vdc, but the Arduino uno only has 1 (?). Does this mean the switch (center pin) and the motion sensor share the same +5vdc pin in the Arduino? (does it matter which order you connect the three motion sensor points into the arduino too?)

sspence (author)  Hermes.Mauricio.Duarte7 months ago
yes, they share the same +5vdc. the motion sensor typically has three pins, one is ground, one is 5v. the out has to connect to whatever pin you specify in code.
alighaddar2710 months ago
sspence (author)  alighaddar2710 months ago
That should work fine.
fordjoe11 months ago

Is it safe to use this 25A SSR ( http://amzn.to/1rVuILv ) if I am only using it to control a 4 Amp vacuum?

sspence (author)  fordjoe11 months ago
Sure. It's rated for a max of 25 amps. It will control anything less than that.
hasnatk sspence11 months ago

Is it possible to activate two sensor at the same time?

i think delay(---) is the main problem.

because triggering two sensor at the same time by human motion is impossible.

if one sensor goes to high then wait until delay() is completed.

what do you think? Is there any idea to overcome? your comment is appriciated.

sspence (author)  hasnatk11 months ago

Redusing the delay would allow near realtime multiple sensor activation. Using interrupts would allow multiple reads very quickly. Larger Atmel chips have more interrupts available.

hasnatk sspence11 months ago

Thanks for your comments and suggestion.

yeah short dealy() is good for another trigger. but usually we need one sensor activates and stay some time for light up.

however, by this time if another motion is occurred, the other sensor should be activated.

How to add another PIR sensor in this circuit??? i.e. how to connect two PIR sensor in a single circuit??? If i cross either of the sensor means the light should glow.

sspence (author)  sriramsrikp1 year ago

We are using pin 2 for the data connection of our sensor, add a second sensor to pin 3.

1. in the code, add (in the appropriate places):

int pirPin2 = 3;

pinMode(pirPin2, INPUT);

motionDetect2 = digitalRead(pirPin2);

2. and replace

if (motionDetect == HIGH)

with

if (motionDetect == HIGH || motionDetect2 == HIGH)

Thankyou very much for ur reply sir. Could you please tell me that where i have to add the first part code in the existing code??

sspence (author)  sriramsrikp1 year ago

Right after the existing lines that match:

after

int pirPin = 2;

put

int pirPin2 = 3;

-----

after

pinMode(pirPin, INPUT);

put

pinMode(pirPin2, INPUT);

----

after

motionDetect = digitalRead(pirPin);

put

motionDetect2 = digitalRead(pirPin2);

After the modifying the existing code with the above one , the circuit have to work as i am thinking. If i cross any one of the two PIR sensors means the bulb will glow for 3 mins. suppose if i crossed any one of the two sensor, the bulb is started glowing for 3 mins. With in that 3 mins if cross the same sensor or another sensor means the time wil be reset for 3 mins and the wil glow for 3 mins. It wont bling once while the time is getting reset. Am i correct sir?? And the 5vdc and ground in the diagram mentioned is 5vdc adapter connected to the circuit. Am I correct sir?? This is my first Arduino project sir. Thats y I am clarifying my doubts this much. I hope u dont mind. Thank you sir.

sspence (author)  sriramsrikp1 year ago

The +5vdc is the 5vdc from the arduino, not the input. power to the arduino comes from a USB cable or a power supply using the barrel jack (9-12v typically).

Hello sir, I tried the coding for restart the timer if new event is seen by the sensor. But no success. could u pls help me by providing the code for that??

And where I have to add the LDR coding in the main code??

Pls help...

sspence (author)  sriramsrikp1 year ago

The code is not currently written to restart the timer if a new event is seen, but it could easily be made to.

Sir, In the schematic diagram, +5vdc is connected to either pin 11 or pin 12 with the help of switch s1 to transfer the positive charge to the circuit. But the Ground also connected to the same pin 11 and pin 12. Here the both +ve and -ve terminals are connecting in one pin itself. Will it create short circuit?? If not means how that part is working??

And what will be the code to restart the timer if a new event is seen??

Thank you sir...

sspence (author)  sriramsrikp1 year ago

Gnd is not shorted to 11 & 12, there are pulldown resistors in line. This prevents floating inputs. I do not have the time right now to build the timer restart code. It's not that difficult, give it a try.

ok sir. I will try. Thank you for spending some time to answering for my clarifications. :-)

Soulfien1 year ago

There is an error in the code. The delay cannot be adjusted to a small duration (5 seconds). It wasn't until I added in this line to the void loop that it worked as I wanted it to:

digitalWrite (ssrPin, LOW);

You have that line in the setup and that wasn't working. I added it to the loop and the delay was then able to actually shut off the light the moment the delay ended.

sspence (author)  Soulfien1 year ago
Awesome. Thank you.
Oliverhall1 year ago

Nice tutorial!

You can get the hc-sr501 PIR motion sensor for cheap here: http://voltatek.com/en/sensors/69-motion-sensor-m...

MadridFC1 year ago
My SSR operates when the DC volatge is 12V.so i even if my arduino gives a high the ssr doesnt close the switch and my lamp doesnt glow.what to do?
sspence (author)  MadridFC1 year ago
SSR's don't switch DC, They switch AC. You need a MOSFET.
1-40 of 53Next »