PIR Sensor with Raspberry Pi

PIR Sensor with Raspberry Pi

PIR Sensor is a passive infrared sensor which senses IR (Infrared) emitted by humans (all objects emit a certain amount of IR). A hotter object emits more IR than a colder one.

The PIR Sensor is also called as Pyroelectric IR Sensor, Passive Infrared Sensor or IR Motion Sensor. The applications of PIR are Burglar Alarm, Motion detected Floor Lamps, Automatic Door Open System and more.

The PIR Works on a change in the difference of IR Levels on the two Layers of its Lens. Means, the sensor (Inside the round metal with a rectangular crystal in the center) is split into two half on the Lens Area, where signals are opposite to each other.

In default condition on the two layers, the difference in two signal will cancel each other and don’t trigger any output. When a human crosses, the variation of IR levels in PIR output’s a trigger. This trigger signal is then processed and output the signal by an IC on the PIR Module.

PIR-Sensor-WorkingNote: The sensitivity and delay time of the sensor can be adjusted on the module by the two potentiometers on it.

Sensitivity: The sensitivity determines the Range of the Sensor. It ranges from 3 to 5 meters.

Delay Time: It determines how long the output of the PIR Sensor remains HIGH.

In this project, we will see how to use PIR Sensor with Raspberry Pi and will light up an LED (You can use buzzer alternatively).

We will write a python code to detect a human presence and turn ON an LED during the trigger time. So whenever a human presence is detected the PIR Sensor will output a HIGH Signal (+5v or +3.3v). According to the delay time we set on PIR Sensor the LED will turn ON during that period. When no human presence is detected the PIR Sensor output’s a LOW Signal.

Circuit Diagram:

PIR Sensor with Raspbberry Pi_bb


Steps to Run our Python Program:

Step 1:

On the desktop, right click and create a text document. Name it as ‘PIRtest.py’ and save.

Step 2:

Now open terminal, type ‘cd Desktop’ to navigate to the desktop.

Step 3:

Open the file in nano editor by using the command,

It will open the file, copy paste the code given above and save it by pressing Ctrl+X. And type y to save it.

Step 4:

Once everything is setup, run the file using the command

Wave your hands in front of PIR Sensor. You can able to see the light will Turn ON according to the time delay set on PIR. Similarly, the print command will display the result on the screen.

Share this post

Leave a Reply

Your email address will not be published. Required fields are marked *