Introduction: Introduction to PIR Sensor and Integrating It With Arduino .
This Tutorial gives a Complete Description of PIR Sensor and its working. Also , it teaches us how to integrate PIR with Arduino.
(This Tutorial is First in our series about Various types of Sensors. Follow Us to get know about other sensors in detail)
- To buy PIR sensor and Other Interesting Stuff , Please visit robotscraft.com
- For More Tutorials Follow-
P.S - We are Open to Feedback. Your Feedback will help us to Make better Tutorials.
Regards,
Team RobotsCraft
Step 1: What Is PIR Sensor?
PASSIVE INFRARED SENSOR is a type of Object Detect Sensor. Object Detect Sensors are of Two Types
- Active Object Detect Sensor
- Passive Object Detect Sensor
Object presence sensors and proximity sensors require an active source of a magnetic field, ultrasound, or infrared radiation. A passive infrared sensor does not require any such source, and responds passively to heat radiated from the object that is being detected.
Step 2: What PIR Does?
A passive infrared motion sensor, often described as a PIR, detects black-body radiation, which all objects emit as a function of their temperature relative to absolute zero. The sensor responds to infrared radiation centered around a wavelength of 10μm (10 microns, or 10,000nm). This is the approximate body temperature of people and animals.
The word “passive” in the term “passive infrared” refers to the behavior of the detector, which receives infrared radiation passively. Proximity sensors must generate their own infrared radiation actively, which is interrupted or reflected by nearby objects.
Step 3: Schematic Symbol
Schematic symbols that are sometimes used to represent a passive infrared motion sensor are shown in above Figure
Step 4: Typical Applications of PIR
1) Motion-sensitive outdoor lighting almost always is based around a PIR. Similarly, a security system may sound an alarm or activate a video camera when a PIR indicates human activity.
2) Wildlife monitoring systems use PIRs to start a video camera that can then run for a preset interval.
3) Warning systems for automobiles have been developed that use a rear-facing PIR to detect pedestrians.
4) Industrial indoor lighting may use PIRs that switch the lights on automatically when people enter a room, and then switch the lights off (after a timed delay) when people are no longer detected in the room. The goal is to prevent wastage of energy as a result of employees forgetting to switch the lights off.
Step 5: How PIR Works?
A PIR module contains multiple components. Most visible is an array of at least 15 small lenses that focus infrared light from zones in the environment onto a pyroelectric detector, also known as a pyroelectric sensor. The response of the detector is processed by an amplifier, so that the signal can trigger an electromechanical relay or solid-state relay .The relay operates an external device such as a light or an alarm.
Additional circuitry may allow the user to control the sensitivity of the PIR module and the length of time that the relay remains closed. The user may also be able to set the time of day when the PIR is active, or an additional phototransistor can shut down the PIR during daylight hours. If a phototransistor is included, its sensitivity is adjustable.
Step 6: Introduction to PyroElectric Sensor
The pyroelectric detector is actually a type of piezoelectric device. It is based around a wafer of lithium tantalate, which generates a small voltage in response to incident thermal radiation.
However, like other piezoelectric components, it does not respond to a steady-state Input, and must be activated by a transition. This distinguishes it from other types of light sensors, such as an infrared photodiode, in which the response is consistently related to a temperature input
Step 7: Response of PyroElectric Sensor Over the Period of Time
The Response of PyroElectric Sensor is Shown in Above Figure
Step 8: Elements Inside PIR Sensor
A pyroelectric detector in a PIR module is mounted in a sealed metallic container, as Shown in above Figure-A. The rectangular window in the detector is usually made of silicon, which is opaque to visible wavelengths but transparent to long-wave infrared radiation.
The pyroelectric detector used in a PIR contains at least two elements with opposite polarities, connected in series. If a sudden change in temperature affects both elements equally, their responses will cancel each other out. Thus, the detector ignores changes in ambient temperature. However, if a source of infrared radiation in the appropriate waveband affects one element before the other, the detector will emit two pulses of opposite polarity
The next step Shows the Effect of Output when radiation falls on both the elements on different times.
Step 9: Effect of Output When Radiation Falls on Two Pyroeletric Elements
Top: In a pyroelectric detector, if a change in temperature affects two elements of opposite polarity simultaneously, their voltages cancel each other out.
Bottom: if one element is triggered before the other, the detector emits a signal
Step 10: Variants of PIRs
PIR sensor modules are available mounted on a small board such as the one shown in above Figure. The detection range is 5 to 10 meters, selected by a jumper on the board. The three pins visible in the photograph are for power supply (3VDC to 6VDC), ground, and output. The output can source up to 23mA with a 5VDC power supply. Power consumption of the module is only 130μA when it is idle, or 3mA when it is active but has no load.
A board of this type still requires additional components to set the “on” time for a light or alarm, and to deactivate the PIR during daylight hours. A PIR can be bought as a single component containing two elements and FET transistors to amplify the signal. Surface-mount and through hole versions are available, requiring a typical power supply of 3VDC to 15VDC. However, a PIR bought as a “bare” component requires significant external circuitry, using comparators or op-amps. Circuit design is nontrivial, entailing practical problems such as op-amps being sensitive to voltage spikes caused by activating a relay that shares the same power supply
Step 11: What Can Go Wrong During Measurement
Temperature Sensitivity
In warmer weather, objects in the field of view of a PIR will tend to be warmer, and the temperature difference between them and human skin will diminish. This can degrade the performance of a PIR.
Detector Window Vunerability
The silicon window on a detector is vulnerable to dirt or grease. Avoid touching the component if it is not protected by lenses.
Mositure Vunerability
Water absorbs far-infrared light. Consequently, condensation on the lens or detector can
degrade performance, and a PIR may not function in heavy rain or snow.
Step 12: Arduino and PIR Interface Circuit for Relay Trigging
Above Figure Shows Ardunio and PIR interface circuit For Relay triggering. Relay will get Triggered when PIR gives and Output.
Step 13: Arduino Code to Integrate PIR and Trigger a Relay.
int Relay_PIN = 9; // choose the pin for the LED
int Sensor_Pin = 2; // choose the input pin (for PIR sensor)int pirState = LOW; // we start, assuming no motion detected
int val = 0; // variable for reading the pin status
void setup()
{ pinMode(Relay_PIN, OUTPUT); // declare LED as output pinMode(inputPin, INPUT); // declare sensor as input Serial.begin(115200); }void loop()
{ val = digitalRead(Sensor_Pin); // read input value if (val == HIGH) // check if the input is HIGH { digitalWrite(Relay_PIN, LOW); // turn Relay ON, Relay is low level triggered if (pirState == LOW) // we have just turned on { Serial.println("Hey We found you moving!"); // We only want to print on the output change, not state pirState = HIGH; } }else
{ digitalWrite(Relay_PIN, HIGH); // turn Relay OFF if (pirState == HIGH) { // we have just turned of Serial.println("Please stop"); // We only want to print on the output change, not state pirState = LOW; } } }