PIR Sensor
PIR Sensor stands for
Pyroelectric (passive) InfraRed sensor, which allows us to detect human or object
movement within a certain range. They are small, low-cost, low-power, easy to
use and long lasting. PIR sensors are adopted in myriads of projects as they
are easy to use with popular hardwares such as Arduino and raspberry pi. PIR
sensors are commonly used in security alarms and automatic lighting
applications.
Working of PIR sensor
PIRs are basically made of
a pyroelectric sensor, which can detect levels of infrared radiation and convert
IR energy to electrical signal. All bodies with temperature above absolute zero
(0 K) emit infra-red radiation. The higher the temperature, the more radiation
is emitted. The sensor in a motion detector is actually split in two halves. When
a body moves, the sensor detects change in IR levels. The two halves are connected
in a way so that they cancel each other out. If one half sees more or less IR
radiation than the other, the output will swing high or low.
If the human infrared radiation
is directly irradiated on the detector, it will output a signal. The signal
strength depends on distance from body. Farther the distance, lesser is the
irradiation on sensor and lesser is the sensitivity. In order to lengthen the
detection distance of the detector, an optical system is added to focus the
infrared radiation, usually using a plastic optical reflection system or a
Fresnel lens made of plastic as a focusing system for infrared radiation.
In the detection area, the
infrared radiation energy of the human body through the clothing is received by
the lens of the detector and focused on the pyroelectric sensor. The detector
can sense the human body within a field of view . The pyroelectric sensor sees
the moving human body till it is within field of view and then does not see it beyond
that. The infrared radiation constantly changes the temperature of the
pyroelectric material so that it outputs a corresponding signal, which is the
alarm signal.
Most PIR sensors have a 3-pin
connection at the side or bottom. One pin will be ground, another will be
signal and the last pin will be power. Power is usually up to 5V. Interfacing
PIR with Arduino is very easy and simple. The PIR acts as a digital output so
all you need to do read the output state as HIGH or LOW. The motion can be
detected by checking for a high signal on a single I/O pin. Once the sensor
warms up the output will remain low until there is motion, at which time the
output will swing high for a couple of seconds, then return low. If motion
continues the output will cycle in this manner until the sensors line of sight
of still again. The PIR sensor needs a warm-up time with a specific end goal to
capacity fittingly. The settling is adjustable from 10-60 seconds.
The Range of PIR Sensor
Indoor passive infrared: 25 cm to 20 m.
Indoor curtain type: 25 cm to 20 m.
Outdoor passive infrared: 10 meters to 150 meters.
Outdoor passive infrared curtain detector: 10 meters to 150 meters
Interfacing with Arduino
There are three pins in the PIR sensor- Vcc, OUTPUT, GND. We
connect Vcc pin to +5V terminal of Arduino, GND to Ground pin and OUTPUT to any
digital input pin of arduino.
Arduino code
/*
DigitalReadSerial
Reads a digital input on pin 8,
prints the result to the Serial Monitor
// digital pin 12 has a LED attached to it.
int PIR_OUT = 8;
int LED = 12;
// the setup routine runs once when you press reset:
void setup() {
// initialize serial
communication at 9600 bits per second:
Serial.begin(9600);
// make the pushbutton's pin
an input:
pinMode(PIR_OUT, INPUT);
pinMode(LED, INPUT);
}
// the loop routine runs over and over again forever:
void loop() {
// read the input pin:
int State =
digitalRead(PIR_OUT);
// print out the state of the
button:
Serial.println(State);
digitalWrite(LED, State);
delay(200); // delay in between reads for stability
}