PIR Sensor
PIR sensor basically means passive infrared sensor i.e. Detector of infrared radiation. We can use a PIR sensor in various ways. Most of the hall sensors and motion detectors use these type of sensors.
These sensors have various applications, they are used in security devices, alarm systems, motion sensing lights, IOT, and many more such devices. The basic working principle of the sensor is to map the change in IR radiation recieved and put it in useful numbers. Note that we use analog inputs in this sensor for finer details.
Today I will be showing you a simple project on using this sensor during your quarantine😄.
|
Standard PIR sensor. |
How does it work?
A PIR sensor can be broken down in three fundamental blocks
1. The Fresnel lens.
2.The BISS0001 IC.
3.The PIR sensing transistor(Pyroelectric sensing transistor).
The Fresnel lens
This is a converging lens but has a special quality to converge all the infrared radiations to the opening on the PIR sensing transistor's window.
|
The Fresnel lens. |
The BISS0001 IC
This IC is a cheap and effective decoder IC. It helps us decode the signals from the pyroelectric sensing device, following is an link to the data sheet of PIR sensor and the pinout of the IC.
👇
BISS001 IC
PIR sensing device
This device works on accepting passive infrared signals and checking if there is a change in the infrared signals applied. It basically has two windows to do the job. The fist window checks if there's an Ir signal emitter and the second one checks if there have been any changes or fluctuations in the IR signal transferred. So, the first window produces a positive voltage change if it detects IR and the second window creates a negative change if it detects any IR emitter.(emitter can be human or animal or anything that leaves heat signatures).
|
Pyroelectric sensor. |
|
Basic working of the pyroelectric sensor. |
Connections
*Pro-tip: place sensor as shown in the image below before connecting.
Basic layout of PIR sensor HC-SR051.
1. +5V of PIR sensor to 3.3V of Arduino.
2. Ground(GND) to GND of Arduino.
3. Digital Out to PIN number 13 on Arduino.
4. Longer end of active Piezo to pin 12.
5. Shorter end of active Piezo to GND pin.
Code
#include <Servo.h>
int sensor = 13;
int state = LOW;
int val = 0;
void setup() {
pinMode(sensor, INPUT);
pinMode(12,OUTPUT);
Serial.begin(9600);
}
void loop()
{
val = digitalRead(sensor);
if (val == HIGH)
{
if (state == LOW)
{
Serial.println("Motion detected!");
state = HIGH;
for(int i=0;i<10;i++)
{
digitalWrite(12,HIGH);
delay(100);
digitalWrite(12,LOW);
delay(100);
delay(200);
}
for(int j=0;j<10;j++)
{
digitalWrite(12,HIGH);
delay(100);
digitalWrite(12,LOW);
delay(100);
delay(100);
}
digitalWrite(12,HIGH);
delay(2000);
}
}
else {
if (state == HIGH){
Serial.println("Motion stopped");
state = LOW;
digitalWrite(12,LOW);
}
}
}
NOTE: We can use the sensor in always active or always dormant mode, We have used it in always dormant mode.
Comments
Post a Comment