PIR Motion Sensor Automation: The Best Tutorial

 

PIR motion sensor tutorial DIY hacking

PIR motion sensor board

Everyone fantasies a home where all the appliances and devices work on their own without having the need for a user to intervene. This is a small step towards achieving that. Wouldn’t it be great when you no longer have to use a switch to turn ON a lamp when you walk into a room , or better yet when you forget to turn it OFF , it automatically turns OFF by itself when you leave the room? Or even if you want to make a burglar alarm using a PIR motion sensor.Using this easy tutorial and some very cheap and simple components you will be able to make the lamps, fans or other appliances in your room activated automatically when you normally walk into the room. Follow this simple PIR motion sensor hacking tutorial to get started. Have fun with this DIY hacking tutorial!

PIR motion sensor pin out

PIR motion sensor pin out

What are the stuff required to do this project?

  1. PIR Motion Sensor like this : PIR Motion Sensor.
  2. BC547 Transistor like this : BC547.
  3. A 5V relay like this : Relay 5V.
  4. A 7805 Voltage Regulator.
  5. A 1N4001 diode.
  6. Solder dot prototyping board.
  7. Two Pin Screw Connector.
  8. 9V battery.

So how does it work?

Here, we are using a PIR motion sensor. PIR stands for Passive InfraRed. This motion sensor consists of a fresnel lens, a infrared detector and supporting detection circuitry. The lens on the sensor focuses any infrared radiation/wavelengths present around it towards the infrared detector. Our bodies generate infrared heat and as a result this gets picked up by the motion sensor. The sensor outputs a 5V signal for a period of one minute as soon as it detects us.It offers a tentative range of detection of about 6-7 m and is highly sensitive. The output from the sensor (5V) is used to trigger a transistor BC547. The transistor then switches on a 5V relay. The relay correspondingly switches your appliance ON.

Working of a PIR motion sensor DIY hacking

Working of a PIR motion sensor

Step 1 : Assembling the PIR motion sensor and other components

Top View of PIR motion sensor board

PIR motion sensor automation


PIR motion sensor automation

Bottom View: PIR motion sensor

Use a solder dot prototype board like above to assemble and solder the components. Or make your own PCB using the schematic given below. First of all solder the 7805 voltage regulator to the board. Next, solder a 9V battery connector’s wires to the pins of the voltage regulator as shown in the schematic. To find the pinout for the PIR motion sensor look at the picture on the top of the page , or check for markings on it : Vcc(+) , Gnd (-) and output signal (Out). Connect the PIR motion sensor’s Vcc and Gnd to 7805’s output. Connect the BC547 (pin out – Collector, Base , Emitter) collector to one end of the relay coil. The base to the output signal of the PIR motion sensor. And the emitter to the Gnd. The other end of the relay’s coil is connected to the input voltage (9V). Connect a 1N4001 diode with its cathode on the Vcc and the anode on the emitter of the BC547. The diode is used to protect the transistor by preventing any reverse voltage from the relay. Finally connect a two pin screw connector near the relay. The pins of the connector are soldered to the NO (normally open)  terminals of the 5V relay.

PIR motion sensor schematic DIY hacking

PIR motion sensor board schematic

Step 2 : Hooking the PIR motion sensor to an appliance

Depending on what you wish to control using the PIR motion sensor may it be a light bulb , fan , music player ,etc , split one of its input AC terminal wires. While ensuring the other line is connected to AC neutral. At one terminal of the screw connector on the board, connect an AC power line. At the other terminal connect the wire (you just split ) for the appliance you wish to control.

PIR motion sensor automation

PIR Motion Sensor hooked up to the lights on the dressing table

Power the board using a 9V battery. You will see that whenever you are within 6-7 m of the radius of the PIR motion sensor , the light or whatever appliance you connected to the board turns ON. The board switches OFF after about a minute when your no longer near the radius of vision of the PIR motion sensor. Depending on the PIR motion sensor you posses, it might have the capability to adjust the sensitivity or delay time for switching, adjust it correspondingly till it reaches the sweet spot.

You can even connect this PIR motion sensor to an arduino. Write code for the arduino checking whether 5V output is coming from the PIR motion sensor and correspondingly do actions. Using an arduino you will be able to do more complicated tasks like adding extra variables of time, etc. You will be even able to make burglar alarm/securiy systems using the PIR motion sensor . Let your imagination go wild with this DIY hacking tutorial for a PIR motion sensor.

PIR motion sensor automation

The PIR Motion Sensor hooked up to the dressing table lights

In this video I am demonstrating how the PIR motion sensor can be used to automate the lights near your dressing table. It detects my presence and switches the lights on the dressing table ON. It stays ON for about a minute and then switches OFF when it no longer detects my presence. This sensor has a very high sensitivity, hence it detects the presence of a person immediately with minimal delay. The PIR motion sensor in action :

Recommended Posts
Showing 53 comments
  • Bryan Tolley
    Reply

    Hello Arvind, I’m curious why you have a 5v relay being fed from 9v VCC? Shouldn’t you use a 9v relay or perhaps use the 7805 for your supply? Also, the diode doesn’t seem very effective where it is. Wouldn’t it be more effective placed across the relay coil to protect the transistor? What do you suggest?
    Bryan

  • Burak
    Reply

    Hello, I really like your project. Is it possible to add a LDR to this project? If it is possible could you please share your sources even a link may figure it out for me :) by the way I’don’t want to waste an arduino or any development card for it, thanks in advance.

  • SAUMITRA KAPOOR
    Reply

    Nice work :)

  • Christopher Gaspar
    Reply

    Good Day! I really liked your project. I cant afford to provide an arduino and other microcontroller. Can this be connected in 555 timer so that i can control the time? Hoping for your response!

  • JPS Bhullar
    Reply

    I have our motion sensor and arduino 5v relay module. Do I need to use transistor or diode. As motion sensor can be given 5v input power and will generate 5v output signal which can be given to 5v relay module directly.
    Kindly tell do I need to use transistors?

  • Koon
    Reply

    Hi may i know what is the use of transistor in these case?

    • BEN JANSE
      Reply

      to trigger the relay

  • Jai
    Reply

    Great tutorial, I have one query. If I use a 5v supply (USB Charger), can I skip the 7805?

    • Manny
      Reply

      I am also wondering this; is the regulator necessary at all?

      • Burak
        Reply

        Nope guys you don’t need 7805 if you have a 5v source to feed.

  • Robert V
    Reply

    Could you remove the 5v regulator and use a mains plug in 5v power supply to power your entire circuit? Thanks

  • pramod
    Reply

    dear sir, my relay is continuolsy switching, why this happening. I traced all cirucit, relay then also swiching back to back at interval of 2 sec.

  • Otto Abrahams
    Reply

    Hi Mr Sanjeev,
    Could you please inbox me a circuit diagram showing how I can wire a PIR sensor in such a way that it will switch on my light bulb and leave it on permanently until it is toggled off by another signal?
    Thanks in advance.

  • grace
    Reply

    how can connect pir motion sensor to automate an alarm system,dressing light,fun,n wheneva I enter the room and leave,at the same time

  • grace
    Reply

    am glad for this project,I want to do a project using motion sensor in security system ,how WL I connect buzzer to the pir sensor

  • grace
    Reply

    am glad for this project,I want to do a project using motion sensor in security system

  • Zanib
    Reply

    Please elaborate which terminals of the relay are X1-1 and X1-2, and how to connect these to a DC appliance, I am a bit confused

  • Bhaskar Singj
    Reply

    Thank you Sir :)

  • Sam Miranda
    Reply

    Hi Arvind,

    I just noticed that your LM7805 has no capacitors. How come?

    I saw most of circuits with this should have caps.

    • Arvind Sanjeev
      Reply

      Hello Sam,
      Usage of caps is recommended, I wanted to minimize the components used and hence designed it this way.

  • Bhaskar Singj
    Reply

    One more thing..this can be implemented to a room.for which a person enters a room and light gets on until man stop walking..?? Like an automatic office lights..

    • Sam Miranda
      Reply

      From my understanding and experience (i do have a pir with leds w/c i bought and destroyed (lol!) by directly using the output in the relay) it will only last for several seconds.

      Even if you are already in the room and constantly moving, it will stop and once it senses movement, it will open again, i think using arduino as mentioned will change the setting/timer.

      This circuit suits my next project as some sort of security alarm (instead of sound, i will use a very bright light as i do not want to get disturb my neighbors but instead surpise the intruders with light) in the perimeter of my apartment.

    • Arvind Sanjeev
      Reply

      Definitely :)

  • Bhaskar Singj
    Reply

    Hello sir,
    I have done this circuit.. But i am facing a problem.. my light does not stay longer..relay cut’s off the lights..it continuously do this..what is the problem??? Plz do reply sir…waiting for your rply.

  • William
    Reply

    How long does the 9v battery last?

    • Arvind Sanjeev
      Reply

      Not very long, will suggest using AA batteries or a DC adapter.

  • Sumer
    Reply

    Hello!
    I liked your tutorial. I an a beginner and I wanted to ask you whether you have a complete video tutorial for this?
    If any, please email it to me at sumerthakur2000@gmail.com
    Thank you

    • Arvind Sanjeev
      Reply

      Not yet :) but have documented everything in this tutorial.

  • Gokul
    Reply

    Hi Arvind,

    Can I use the newly released Rpi 2 for this project (http://diyhacking.com/getting-started-with-internet-of-things-raspberry-pi/)
    Any major changes that i need to take care of?

  • Gokul
    Reply

    Being a beginner,not aware of the get/post methods ..
    Can i get an updated code for the bulb status.
    Also will a current sensor in the circuit work for getting the status ?

  • Gokul
    Reply

    Also I would like to know how to get the status of the bulb in the web interface ?

    • Arvind Sanjeev
      Reply

      You would probably have to write back to the text file through http get/post methods to update the status of the bulb.

  • Gokul
    Reply

    Hi Arvind,

    Thanks a lot for your tutorials.
    I am currently working on this project on Home automation using Raspberry pi.
    I went through this link:
    http://diyhacking.com/getting-started-with-internet-of-things-raspberry-pi/

    Here you had done it using a Web UI..I want to do this on an android app as well..can you help me with this and also I would like to know in what way is Raspberry pi advantageous in Home automation compared to other boards like arduino,intel,beagle bone etc??

  • Mior
    Reply

    1)But this sensor will detect animals? such as cat?
    2)I want to use this project for bedroom…normally student lazy tu switch off the light and fan..so if i want to make it more than 1 PIR sensor..how i want to add it on circuit?

  • Shiqin
    Reply

    Hello Mr Arvind,

    Can the on off of the light be controlled by both sensor&switch?

    Is it possible to take the input voltage of the circuit directly from socket(240V ac) by putting an adapter(9V dc)?

    Thank you.

    • Arvind Sanjeev
      Reply

      Hi Shiqin,
      Yes, you can connect this module in parallel to the lamp, so that you can turn it ON/OFF from either the switch or the sensor.
      And, yes you can use a 9V DC adapter to power this module.

  • Fatema
    Reply

    Hello
    I really liked your project and it’s exactly what i wanna do for my university project..
    do you think i can do the same thing but with a computer..?? i wanna use the motion sensor to star a video on a laptop when someone walk in the room..
    if yes please tell how to do it

    but you did great there

    • Arvind Sanjeev
      Reply

      Hello Fatema, you can definitely do that using an Arduino. You would have to connect the sensor to arduino, and plug the arduino to the laptop. And then probably write a python program which reads the data via serial port and does whatever you want accordingly.

  • krutika
    Reply

    hey i was doing this project for my third year semester exams.i m stuck halfway.i m doing it on a breadboard.so how should an appliance get connected to it?i reaaly need ur help asap.
    thank you.,

  • Prashant Sultania
    Reply

    Hi Arvind,

    You have done really good job. I want to implement the same in my house. I will need your guidance for this. Can you help me in this? please share your me your contact details on my email id.

    • Arvind Sanjeev
      Reply

      Hey, if it is regarded to this project, please share your thoughts here, so that others could also benefit from it. Else you could reach me on ars@diyhacking.com.

pingbacks / trackbacks

Leave a Comment

11 − = 7

Start typing and press Enter to search