A comprehensive breakdown of PIR sensors

Introduction to PIR sensors

PIR sensors consist of a pyroelectric sensor, which is a material that generates an electric charge when exposed to heat. The sensor has two slots that are sensitive to infrared radiation. A Fresnel lens or a mirror is used to focus the infrared radiation onto the slots. When the sensor is idle, both slots receive the same amount of infrared radiation from the surroundings. However, when a warm object, such as a person, passes by the sensor, it causes a difference in the amount of infrared radiation received by the two slots. This difference is converted into a voltage change, which triggers the detection.

The range and sensitivity of PIR sensors depend on various factors, such as the size and shape of the lens or mirror, the number and configuration of the slots, and the temperature and characteristics of the objects being detected. Different types of PIR sensors are available for different applications, such as indoor or outdoor use, wide or narrow field of view, and long or short detection distance.

PIR sensors are easy to use and have low power consumption. They are also inexpensive and durable. However, they also have some limitations, such as being affected by ambient temperature changes, sunlight, or other sources of infrared radiation. They also cannot distinguish between different types of objects or provide detailed information about them.

Schematics of PIR sensors

PIR sensors schematic

A pin sensor has three pins: View the datasheet here

  • VCC: This pin is connected to the supply voltage. It supports a minimum of 4.5V and can take up to 12V.
  • GND: This pin is connected to ground of the circuit.
  • OUT: This pin is the output pin of the PIR sensor.

Off-Time Control: The duration of the output pulse is determined by the off-time control, which is a combination of a resistor and a capacitor connected to the sensor circuit. The off-time control sets the minimum time between each output pulse. By adjusting the off-time control, one can change the sensitivity and responsiveness of the PIR sensor. The off-time control is a variable resistor(preset) that can be turned using a screwdriver.

Sensitivity Control: The sensitivity control of a PIR sensor is a knob that allows you to adjust how much infrared radiation the sensor can detect. By turning the knob clockwise, you can decrease the sensitivity, which means that the sensor will only trigger when the motion is more intense or closer to the sensor. By turning the knob anti-clockwise, you can increase the sensitivity, which means that the sensor will trigger even when the motion is subtle or far away from the sensor. 

How PIR sensors work

A PIR sensor has two slots that are sensitive to infrared light. Each slot is covered by a lens that focuses the infrared radiation onto a pyroelectric sensor inside the device.

When the sensor is idle, both slots receive the same amount of infrared radiation from the environment. This causes no change in the output signal of the sensor.

When a warm object, such as a human or an animal, passes by the sensor, it interrupts the infrared radiation in one of the slots. This causes a positive or negative change in the output signal, depending on the direction of the movement.

When the warm object leaves the sensor’s range, the opposite change occurs in the output signal. This creates a pulse that indicates motion detection

How to use PIR sensors in analog circuits

In this circuit, the PIR sensor is connected to the 4.5V battery and the base of the transistor through a 1k ohm resistor. The transistor acts as a switch that controls the current flow to the buzzer. The transistor used is an NPN transistor (BC547). The buzzer is connected to the collector of the transistor and the 4.5V battery. When the PIR sensor detects motion, it sends a high signal to the base of the transistor, which turns it on and activates the buzzer. When the PIR sensor does not detect motion, it sends a low signal to the base of the transistor, which turns it off and deactivates the buzzer. 

PIR sensors in analog circuit
PIR sensors in analog circuit

How to use PIR sensors in digital circuits

To use a PIR sensor in an Arduino circuit, you need to connect it to a digital pin and read its output. Here are the steps to do that:

  • Connect the Vcc pin of the PIR sensor to the 5V pin of the Arduino.
  • Connect the GND pin of the PIR sensor to the GND pin of the Arduino.
  • Connect the OUT pin of the PIR sensor to any digital pin of the Arduino.
  • Define the PIN of the PIR sensor as an input in the setup() function of your code. For example, pinMode(2, INPUT);.
  • Read the value of the PIR sensor using the digitalRead() function in the loop() function of your code. For example, int val = digitalRead(2);.
  • If the value is HIGH, it means that motion is detected. If the value is LOW, it means that no motion is detected. You can use this information to control other devices, such as LEDs, buzzers, or relays.

In this example, we will turn an LED on whenever the PIR sensor is triggered. We will be using an Arduino uno R3 as the microcontroller.

  • Connect the Vcc pin of the PIR sensor to the 5V pin of the Arduino.
  • Connect the GND pin of the PIR sensor to the GND pin of the Arduino.
  • Connect the OUT pin of the PIR sensor to the digital pin 2 of the Arduino.
  • Connect the anode of an LED to digital pin 9 through a resistor, and connect the cathode to GND of the Arduino.
  • Open your Arduino IDE and upload the following code.
int sensor =2;
int light =9;
void setup()
{
  pinMode(light, OUTPUT);
  pinMode(sensor,INPUT);
}

void loop()
{
  int state =digitalRead(sensor);
  if (state==HIGH){
    digitalWrite(light,HIGH);
  }
  else {
    digitalWrite(light,LOW);
  }
  
}

The following function “digitalRead” obtains the current state of the PIR sensor and stores it in the variable “state”.

int state =digitalRead(sensor);
PIR sensor in digital circuit
PIR sensor in digital circuit

Application and uses of PIR sensors

  • Security and motion detection: PIR sensors can detect the presence of humans or animals by sensing the changes in infrared radiation levels.
  • Energy-efficient lighting control: PIR sensors can automatically turn on or off the lights based on the occupancy of a room or area. 
  • Industrial automation: PIR sensors can be used to monitor the activity of workers, machines, or products in factories or warehouses. 
  • Smart HVAC management: PIR sensors can adjust the heating, cooling, or air conditioning systems according to the number of people in a building or a zone. 
  • Hands-free appliance activation: PIR sensors can activate or deactivate appliances such as faucets, soap dispensers, or trash cans without touching them. 

Related post

Leave a Comment