Learn how to use a PIR motion sensor to automate lamps, fans, and other appliances.
Ever fantasize about having a home where all the appliances and devices work on their own without the need for a user to intervene? This project is a small step toward achieving that. Wouldn't it be great if you no longer had 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 itself off when you leave the room? You can even make a burglar alarm with a PIR motion sensor if you want! With some cheap and simple components, you will be able to make the lamps, fans, or other appliances in your room activate automatically when you walk into the room. Follow this simple PIR motion sensor hacking tutorial to get started.
How Does the PIR Motion Sensor Work?
Here, we are using a PIR motion sensor. PIR stands for Passive InfraRed. This motion sensor consists of a fresnel lens, an 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 detection range 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.
How a PIR motion sensor works
Assembling the PIR Motion Sensor and Other Components
PIR motion sensor automation
Bottom View: PIR motion sensor
Use a solder dot prototype board like the one shown above to assemble and solder the components. Or make your own PCB using the schematic given below. First, solder the 7805 voltage regulator to the board. Next, solder a 9V battery connector's wires to the pins on the voltage regulator as shown in the schematic. To find the pinout for the PIR motion sensor, look at the picture at the top of the page or check for markings on it: Vcc(+), GND (-), and the output signal (Out). Connect the PIR motion sensor's Vcc and GND to the 7805's output. Connect the BC547 (pin out - Collector, Base, Emitter) collector to one end of the relay coil. Connect the base to the PIR motion sensor's output signal and the emitter to theGNDd. 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 n the 5V relay.
PIR motion sensor board schematic
Hooking the PIR Motion Sensor to an Appliance
Depending on what you want 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 want to control.
PIR Motion Sensor hooked up to the lights on a 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 you're no longer near the vision radius of the PIR motion sensor. Depending on the PIR motion sensor you have, it might have the capability to adjust the sensitivity or delay time for switching. Adjust it correspondingly until it reaches the sweet spot.
You can even connect this PIR motion sensor to an Arduino. Write code for the Arduino checking whether the 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/security systems using the PIR motion sensor. Let your imagination go wild!
The PIR Motion Sensor hooked up to the dressing table lights
In the video below, I demonstrate 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.