PIR sensor, which stands for Passive Infrared Sensors, is an electronic component used to detect the infrared radiation emitted by the human body. It senses the presence of a person by detecting the infrared radiation in the surrounding environment, and is commonly used as a motion detector in the security field.

Working Principle of PIR Sensor
The core principle of the PIR sensor is the pyroelectric effect, which means that certain crystals will generate an electric charge due to temperature changes. The human body has a constant temperature, typically around 37 degrees Celsius, and emits infrared radiation at a specific wavelength of about 10um. When a person enters the detection area of the PIR sensor, the generated infrared radiation affects the PIR, causing it to produce a charge signal, and when the person leaves the detection area, the charge returns to equilibrium.
Main Components of PIR Sensor
Filter: Allows only infrared radiation within a specific wavelength range to pass through, making the PIR sensor sensitive only to the human body and unaffected by other heat sources like sunlight or artificial lights.
Fresnel Lens: Focuses external light onto the PIR, increasing the amount of incoming light, thereby greatly enhancing the detection distance and angle of the PIR.
Characteristics of PIR Sensor
Low Power Consumption: Typical consumption is around 10uA.
Low Cost: Prices can range from a couple to several dollars.
Easy to Use: The simplest setup only requires detecting a pin level signal.
Applications of PIR Sensor
PIR sensors are widely used in various fields, including security, smart home, and automation control. In the security field, PIR sensors are often used to detect intruders and can be combined with other security devices, such as alarms and surveillance cameras, to enhance the overall effectiveness of the security system. Additionally, PIR sensors can be used in consumer products like doorbells, peepholes, motion switches, and night lights.

int stl=0;//integer variable
void setup()
{
Serial.begin(9600);//initialize serial port
pinMode(A0, INPUT);//set analog pin A0 as input
pinMode(2,OUTPUT);//set digital pin 2 as output; output two states, low and high
}
void loop()
{
stl=analogRead(A0);//read A0 pin, sensor status
if (stl > 0)
digitalWrite(2,HIGH);//if input detected, led turns on
if (stl ==0)
digitalWrite(2,LOW);//no input, led turns off
delay(500);//delay 0.5 seconds
}
The simulation result shows that when there is movement within the measurement range, the sensor outputs a high level and the led lights up
When there is no movement within the measurement range or when there is no one present, the led turns off.
