PIR Sensor Working Principle

PIR sensors are used in a wide variety of applications such as lighting control, smart home, and IoT applications, Automatic door opening system, Security alarms based on PIR sensors, and Human detection robots in search and rescue operations in disasters, multifunction printers, etc. So let's understand what is a PIR sensor and how it works so we can use it in our projects.

PIR Sensor Working

What is a PIR Sensor?

PIR sensor is a small low-priced Passive infrared motion detector sensor. As the name suggests it doesn’t emit radiation (unlike an Infrared (IR) sensor which emits infrared radiation) but it detects the changes in infrared radiation of the source. It's very facile to use and hence used in diverse applications.

PIR sensor

PIR Sensor Working Principle

It works on the principle that whenever it detects a change in infrared radiation, it generates a digital output signal.

PIR Sensor Working Principle

PIR sensor consists of a fresnel lens, pyroelectric material (metal can and a rectangular crystal). A Fresnel lens which is made of high-density polythene concentrates the incoming infrared radiations so that they fall on the pyroelectric material. Metal can help to make the sensor more immune to temperature, humidity, and noise. Pyroelectric material detects the changes in infrared radiation and generates an output signal.

It is made up of 2 slots of special material sensitive to IR. When a person comes in the range of the sensor, the first slot creates a positive differential voltage and when the person leaves the second slot creates a negative differential voltage. These changes are detected.

This output signal is further processed by the external circuitry and converted to digital output.

What does the PIR sensor do?

In a nutshell, the PIR sensor detects motion and gives a corresponding digital output.

How to connect the PIR sensor with Arduino?

PIR Sensor has 3 pins: VCC or 5V, Gnd, and a digital output pin. This digital pin is used to communicate with the microcontroller.

Connection diagram

How to connect the PIR sensor with Arduino

As shown in the image, Vcc goes to 5V, Gnd goes to Gnd, and Output is connected to digital input pin 2 of Arduino. 

Whenever there is motion detected output pin of the PIR motion sensor goes high. So based on this result we can read the digital input pin 2 of the Arduino and take the action such as glowing LED.

You can put the PIR sensor in two modes as shown in the above image the jumper is used to connect it in H mode repeatable trigger and L mode non-repeatable trigger. In retriggering or H mode, the LED stays on while the person is moving in the PIR sensor range. Whereas in non-retriggering or L mode, LED blinks or turns on and off every 1 second when a person is moving in the PIR range.

Also, there are two potentiometers of 1M ohm resistance available for adjusting sensitivity and time delay as shown in the image. 

The sensitivity pot is used to adjust the distance from 2-5m and the time delay pot is used to adjust the

time for which the output pin should remain high when the motion is detected.

You can set the range from 5 seconds to 5 minutes. Turn it fully anti-clock so

that you can decide the time delay from Arduino.

Below is the Arduino code to detect motion using the PIR sensor:

Arduino code for PIR Sensor

 int led = 13;    // led is connected to pin 13

int sensor = 2;  // output pin of the sensor is connected to digital pin 2

int val = 0;     // variable to store the sensor status (value)

void setup()

{

    pinMode(led, OUTPUT);   // initialise LED as an output

    pinMode(sensor, INPUT); // initialise sensor as an input

    Serial.begin(9600);     // initialise serial

}

void loop()

{

    val = digitalRead(sensor); // read sensor value

    if (val == HIGH)

    {                            // check if the sensor is HIGH

        digitalWrite(led, HIGH); // turn LED ON

        delay(1000);             // delay 1000 milliseconds

        Serial.println("Motion detected!");

    }

    else

    {

        digitalWrite(led, LOW); // if val is low , led pin set to low

        delay(1000);            // delay for 1000 second

        Serial.println("Motion stopped!");

    }

}

What does a PIR sensor detect?

 PIR sensors can detect human or animal motion. Humans emit infrared radiation. When a human comes into the sensing range of the PIR sensor, these changes in radiations are detected by the PIR sensor which causes the output of the sensor to go high.

What does a PIR sensor detect

PIR Sensor Range

PIR sensors are available in a wide range of options:

Indoor curtain-type PIR sensor: Range is between 25 cm to 20 m

Indoor passive infrared: The range is between 25 cm to 20 m

Outdoor passive infrared: The range is between 10 m to 150 m,

Outdoor passive infrared curtain detector: Range is between 10 m to 150 m.

 

In this blog, we have seen what is PIR sensor, how it works and Arduino code for PIR sensor. If you have any questions feel free to comment and ask.

Leave a comment

Please note, comments must be approved before they are published