Has this ever happened to you? You come back from a romantic dinner date and when you open the shutter door of your garage you realize that you left the garage light ON. You spent few hours outside with your partner to impress her and all the time this light bulb was on. You immediately turn around and look at her face to see a silent anger on her face. Alright, enough of that. So, in this tutorial I am going to turn on and off the garage light using a PIR sensor. When the sensor detects a moving object, it turns on the light bulb and when the moving object is gone, it turns it off. Lastly, I am going to make sure that light bulb only turn on during the night time (when its dark).
Has this ever happened to you? You come back from a romantic dinner date and when you open the
shutter door of your garage, you realize that you left the garage lights on. You spend few hours
outside with your partner to impress her and all the time this light bulb was on. You immediately
turn around and look at her face to see a silent anger on her face. Alright enough of that. So in
this tutorial I'm going to turn on and off the garage light using a PIR sensor. When the sensor
detects a moving object, it turns on the light bulb and when the moving object is gone it turns
it off. Lastly I'm going to make sure that the light bulb only turns on during the night time.
In this project I'll be using a PIR sensor along with a LDR to turn on or off a light bulb using
a relay. The things I need to consider before designing the circuit are the bulb should only
turn on when the room is dark and when a motion is detected. The bulb should turn off after 30
seconds of object leaving the sensor's proximity. Most importantly we need to place the LDR in a
place where it doesn't turn off the bulb as soon as it lights up. For this tutorial we need a general
two PIR sensors, two 1N4148 small signal fast switching diodes, one 1N4007 high voltage high
current rated diode, one LDR, one 10k trimmer potentiometer, two 470 ohm resistors, one 10k
resistor, one 1k resistor, one 2N3906 general purpose PNP transistor, one 2N2222 general purpose
NPN transistor, one 5 volt relay, one LED to display the status, five terminal blocks,
one 220 volt to 5 volt buck step down module, few connecting cables and general soldering
equipments. Let's first connect the LDR and set up the light detection bit. As we all know we need
to set up a voltage divider to use the LDR in a circuit. So I'm adding this 10k pot and 470 ohm
resistor to set up the voltage divider bit. By adjusting the resistance of the pot we can
adjust the intensity of the sunlight at which this circuit will operate. Now let's install the PIR
sensor. Connect the VCC to 5 volt and ground to ground. Then connect the IN4148 diode to the
output of the sensor. In this circuit I'm installing just one sensor however in the actual project I
have used two sensors to capture a bit more than 180 degrees. So to avoid the sensors from
backfading each other we need to install a diode to the out pin of each sensor. If you want to
capture motion at 360 degree you may need three to four sensors and diode pair to achieve that.
Now that we have the PIR sensor and the LDR in place we just need to add the AND functionality.
To achieve that I'm adding a general purpose PNP transistor. When a motion is detected AND when the
sunlight is at certain intensity current flows out of the transistor. Next we need to amplify
the current received from the collector of the PNP transistor and turn on and off the LED indicator
and the relay. A general purpose NPN transistor is used to achieve this. That's it we're all done.
So this is what I've made. On my board components are pretty much soldered everywhere
but you may like to have them nicely installed to give it a bit more cleaner look.
Okay so let's check out how this works. Alright I'll place the board on the table to do a quick
test. I haven't hooked up a light bulb to the circuit yet however the LED indicator should
serve the purpose of the demonstration. So now I'm going to turn off the light and make the room dark.
Let's see if the sensor picks up the motion and lights up the LED. Ta-da it works. Now let's turn
off the light of the room and see if the LED indicator turns off or not. Yes that works. Okay
finally just want to make sure that the light bulb turns off after 30 seconds of me moving out
of the sensor's proximity. Instead of having two to three PIR sensors you can use one and install it
at the corner of the wall. However that will require a fair bit of wiring inside the roof or
on the ceiling which will be way more expensive and tedious than installing three sensors and
putting it in the middle of the room. You can also swap the Arduino with a NodeMCU board and do a
to log the time when the sensor detected the motion or when the light went on to record when
people entered your garage and how long they stayed in there. Boom and that concludes the project.
I can now install it on the ceiling and make my partner happy. If you want to know how a LDR works
please watch my tutorial number one which is using a LDR sensor with Arduino. To know how a relay
works please watch my tutorial number four driving a relay with an Arduino. Tutorial number
five talks all about PIR sensor which is PIR sensor tutorial with or without an Arduino.
The setup can be used to automate all outdoor lights, automate lights of basement, garden or
covered parking areas, automate lift lobby or common staircase lights, automate bedside or
night lamps, create a smart home automation and security system and many more. Thanks again for
watching this video. I hope it helps you. If you want to support me you can subscribe to my channel
and watch my other videos. Thanks. See you again in my next video. Bye now.