What is PIR sensor? How to integrate it into Arduino?

Introduction:

Passive Infrared (PIR) sensors have become an essential component of modern security, automation, and IoT systems. In this comprehensive guide, we explore the intricate world of PIR sensors, shedding light on their working principles, diverse applications, and seamless integration with platforms like Arduino and Raspberry Pi.

What is a PIR Sensor?

PIR sensors, short for Passive Infrared sensors, are designed to detect motion by sensing changes in infrared radiation emitted by objects within their field of view. These sensors are widely used in applications ranging from security to energy conservation.

Types of PIR Sensors

There are two main types of PIR sensors:

  • Linear PIR sensors: These sensors detect motion along a line. They are often used in security systems to detect intruders.

  • Pulsar PIR sensors: These sensors detect motion in a wide area. They are often used in applications such as automatic lighting and occupancy sensing.

Working Principle

A PIR sensor works by detecting the change in infrared radiation caused by the movement of an object. When an object moves, it emits more infrared radiation than when it is stationary. The PIR sensor detects this change in radiation and generates an output signal.

The working principle of a Passive Infrared (PIR) sensor revolves around its ability to detect changes in the infrared radiation emitted by warm bodies or objects. When a human being or any warm object enters the sensor's field of view, it emits infrared radiation that can be perceived by the sensor. This radiation carries information about the temperature of the object and its motion. Here's a breakdown of how a PIR sensor operates:

1. Sensor Internal Structure:

A PIR sensor is typically divided into two halves: a positive half and a negative half. Each half has its own circuitry. When the sensor detects changes in infrared radiation, it generates electrical signals from these two halves.

2. Detection of Infrared Radiation:

The Fresnel lens of the PIR sensor is designed to capture and focus infrared radiation from its surroundings. When a warm body moves within the sensor's range, the radiation pattern changes, causing an imbalance between the two halves of the sensor.

3. Signal Generation:

As the warm body moves, one half of the sensor experiences an increase in infrared radiation, while the other half experiences a decrease. This disparity between the two halves generates an output signal, which is essentially the difference between the two signals.

4. Output Signal and Detection:

The generated output signal indicates the presence of a moving warm object. The sensor can distinguish between positive and negative changes in the radiation pattern, which helps it identify the direction of motion.

5. Response and Reset:

Once the PIR sensor is powered on, it goes through a warm-up period to stabilize its internal components and compensate for environmental changes. During this period, the sensor's output remains low. Once the sensor is ready, it continuously monitors the changes in the infrared radiation pattern. If it detects motion, the output signal goes high for a short period of time, typically a few seconds. After this response period, the output returns to its normal low state.

6. Settling Time:

The PIR sensor requires a settling time after detection to avoid false positives caused by temporary environmental changes or fluctuations. This settling time is usually between 10 to 60 seconds, during which the sensor remains in a non-responsive state.

Some Best PIR Sensors in the Market

  • HC-SR501: This is a popular and affordable PIR sensor. It is easy to use and can be used with a variety of microcontrollers.

  • HC-SR505: This is a more advanced PIR sensor that offers better performance. It is also more expensive than the HC-SR501.

  • SR602: This is a PIR sensor that is designed for outdoor use. It is weatherproof and can withstand extreme temperatures.

  • Texecom PIR: This is a PIR sensor that is used in security systems. It is high-quality and reliable.

  • Bosch PIR: This is a PIR sensor that is used in a variety of applications. It is known for its accuracy and sensitivity.

Applications:

In practical applications, the output signal generated by the PIR sensor can be used to trigger various actions, such as activating an alarm, turning on lights, or initiating a notification. The sensor's ability to detect human presence without direct contact and its effectiveness in conserving energy makes it an invaluable tool in security, automation, and energy-efficient systems.

  • Security systems: PIR sensors are used in security systems to detect intruders. They are often used in conjunction with other security measures, such as cameras and alarms.

  • Automatic lighting: PIR sensors are used in automatic lighting systems to turn lights on and off when people enter or leave an area. This can save energy and improve security.

  • Occupancy sensing: PIR sensors are used in occupancy sensing systems to detect the presence of people in a room. This can be used to control lighting, heating, and air conditioning systems.

  • Pet detection: PIR sensors can be used to detect pets. This can be useful for keeping pets out of certain areas or for triggering an alarm if a pet is left alone for too long.

  • Motion-activated cameras: PIR sensors can be used to trigger motion-activated cameras. This can be used to record video footage of people or animals moving in an area.

  • Toys: PIR sensors are used in a variety of toys, such as motion-activated games and robots.

How to Use a PIR Sensor with Arduino

To use a PIR sensor with Arduino, you will need the following:


  • An Arduino board

  • A PIR sensor

  • Jumper wires

The following code can be used to detect motion with a PIR sensor: