one , Pyroelectric infrared sensor is a kind of sensor which can detect infrared emitted by human or animal and output electric signal , It is widely used

Basic knowledge of pyroelectric sensors
Pyroelectric effect is similar to piezoelectric effect , It refers to the phenomenon that the surface of crystal is charged due to the change of temperature . Pyroelectric sensors are sensitive to temperature . It consists of ceramic oxide or piezoelectric crystal elements , In component
Two surfaces make electrodes , The temperature is within the monitoring range of the sensor ΔT The change of time , The pyroelectric effect produces an electric charge on both electrodes ΔQ, That is, a weak voltage is generated between the two electrodes ΔV. Because of its output
Very high impedance , There is a FET in the sensor for impedance transformation . Charge produced by pyroelectric effect ΔQ It's bound by the ions in the air and it disappears , That is, when the ambient temperature is stable ,ΔT=0, Then sensing
There is no output from the converter . When the human body enters the detection area , Because the temperature of human body is different from that of environment , produce ΔT, There are ΔT output ; If the human body does not move after entering the detection area , Then the temperature does not change , The sensor has no output . therefore
This kind of sensor detects the movement of human body or animal . It is proved by experiment , The sensor does not have an optical lens ( Also known as Fresnel lens ), The detection distance is less than 2m, And with the optical lens , The detection distance can be greater than 7m.
Attention should be paid to the following points in use :
one , The DC operating voltage must meet our requirements , Too high and too low will affect the performance of the module , And the power supply must be well regulated and filtered , For example, computers USB Power Supply , Mobile phone charger power supply , compare
old 9V All the stacked batteries can not meet the requirements of the module , It is recommended that the customer use the power supply of transformer and pass through the three terminal voltage regulator chip 220UF and 0.1UF Power supply after capacitor filtering .
two , When debugging, keep the human body away from the sensing area as far as possible , Sometimes the human body is not directly in front of the module , However, when the human body is too close to the module, the module can also sense that there is always output , Also, when debugging, the human body should not touch the circuit part
It will affect the operation of the module , The more scientific way is to connect the output terminal to one LED Or a multimeter , Cover the module with newspaper .
three , The module can work normally without load , Work disorderly after connecting load , One reason is that the power capacity is very small and the load consumes more power , The voltage fluctuation caused by load operation leads to module misoperation , Another reason is negative
When the power is on, it will cause interference , Inductive loads, such as relays or electromagnets, produce a reverse electromotive force ,315M There will be electromagnetic radiation when the transmitter works, which will affect the module . The solution is as follows :A, Power supply department
Add inductance filter separately .B, The method of using different voltage for load and module , for example : Load usage 24V working voltage , Module usage 12V working voltage , It is isolated by three terminal voltage regulator .C: Use more power .
four , The human body sensing module can only work indoors, and the working environment should avoid sunlight , Direct illumination by strong light , If the working environment has strong RF interference , Shielding measures can be adopted . In case of strong airflow interference , Close doors and windows or prevent convection . The induction area should be away from heating appliances and objects as well as sundries and clothes that are easy to be blown by the wind .
five , The human body sensing module is recommended to be installed in a sealed box , Otherwise, there may be an output signal all the time .
six , If the detection angle of the human body sensing module is less than 90 Degree time , The lens can be covered with opaque adhesive tape or reduced by cutting .
seven , Dual probe is used in human body induction module , The movement direction of human hands, feet and head is closely related to the sensitivity , Moreover, the characteristics of the infrared module make it impossible to accurately control the sensing distance .
eight , Probe in module (PIR) It can be soldered on the other side of the circuit board . The probe can also be extended with double core shielding wire , The length should be within 20 It's better to be within one centimeter .
( The above introduction is from Baidu )

two , Function description :
Photosensitive control : Photosensitive control can be set , Not sensitive during the day or when the light is strong .
temperature compensation : In summer when the ambient temperature rises to 30~32℃, The detection range is slightly shorter , The temperature compensation can be used as performance compensation .
Two trigger modes :( Optional jumper )
a, Non repeatable trigger mode : After the induction output high level , The delay period ends , The output will automatically change from high to low ;

b, Repeatable trigger mode : After the induction output high level , During the delay period , If there is a human body moving in its sensing range , Its output will remain high all the time , The high level will not be changed to low level until the person leaves ( After the induction module detects each activity of the human body, it will automatically postpone a delay period , And take the time of the last activity as the starting point of the delay time ).

three , Module parameters :

Operating voltage range : DC voltage 4.8~20V

Quiescent current :<50uA

Level output : high 3.3 V / low 0V

Trigger mode :L Non repeatable trigger /H Repeat trigger ( Default repeat trigger )

Delay Time :0.5-200S( Adjustable ) It can be made in a few seconds - Dozens of minutes

Blocking time :2.5S( default ) It can be made in a few seconds - Dozens of seconds

Circuit board dimensions :32mm*24mm

Induction angle :<100 Degree cone angle

working temperature :-15-+70 degree

four , The schematic diagram is as follows :

five , The physical figure is as follows :

six , working principle
When people enter their sensing range, they will output high level , When a person leaves the sensing range, the high level will be automatically delayed and turned off , Output low level .

The human body has a constant temperature , In general 37 Degree or so , Emit specific wavelengths 10UM Left and right infrared , Passive infrared probe is launched by detecting human body 10UM Around the infrared and work . Human launched 10UM The left and right infrared rays are enhanced by the Fresnel filter and gathered on the infrared sensor .
Pyroelectric elements are usually used in infrared sensors , This kind of element will lose the charge balance when it receives the infrared radiation of human body and the temperature changes , Release charge outward , The subsequent circuit can produce alarm signal after detection and processing .
( This module contains a BISS001 chip , See the link for the reference manual of this chip .)

seven , The module pin connection is shown in the figure below :

eight , Program code :
Because the induction module has about one minute initialization time after power on , During this period, the module outputs at intervals
0-3 second , Standby mode in one minute .
So the procedure is as follows :
1, initialization ( except HC-SR501 Module program ) All programs that need to be initialized .
2, delayed 10 second
3, The buzzer rings 1 second
4, initialization HC-SR501 Module program
5, Turn on interrupt ( Because people enter its sensing range, it outputs high level , When a person leaves the sensing range, the high level will be automatically delayed and turned off , Output low level . So set the rising edge interrupt or double edge interrupt )
#include "hcsr501.h" #include "usart.h" #include "beep.h" #include "delay.h"
u8 flag=0; void Hcsr501_Init(void) { GPIO_InitTypeDef GPIO_InitStruct;
EXTI_InitTypeDef EXTI_InitStruct; NVIC_InitTypeDef NVIC_InitStruct;
RCC_APB2PeriphResetCmd(RCC_APB2Periph_GPIOB,ENABLE); RCC_APB2PeriphClockCmd(
RCC_APB2Periph_AFIO,ENABLE); // open AFIO Clock GPIO_InitStruct.GPIO_Mode=
GPIO_Mode_IPD; GPIO_InitStruct.GPIO_Pin=Hcsr501_Pin; GPIO_InitStruct.GPIO_Speed=
GPIO_Speed_50MHz; GPIO_Init(Hcsr501Port,&GPIO_InitStruct); EXTI_InitStruct.
EXTI_Line=EXTI_Line5; EXTI_InitStruct.EXTI_LineCmd=ENABLE; EXTI_InitStruct.
EXTI_Mode=EXTI_Mode_Interrupt; EXTI_InitStruct.EXTI_Trigger=EXTI_Trigger_Rising;
EXTI_Init(&EXTI_InitStruct); GPIO_EXTILineConfig(GPIO_PortSourceGPIOB,
GPIO_PinSource5); NVIC_InitStruct.NVIC_IRQChannel=EXTI9_5_IRQn; NVIC_InitStruct.
NVIC_IRQChannelCmd=ENABLE; NVIC_InitStruct.NVIC_IRQChannelPreemptionPriority=2;
NVIC_InitStruct.NVIC_IRQChannelSubPriority=1; NVIC_Init(&NVIC_InitStruct); }
void EXTI9_5_IRQHandler(void) { if(EXTI_GetITStatus(EXTI_Line5)!=RESET) { flag=1
;// This sign indicates that someone has entered the sensing range , Specific procedures are written according to individual needs . printf(" Someone broke in !!!\r\n");// For testing }
EXTI_ClearITPendingBit(EXTI_Line5); } #ifndef __hcsr501_H #define __hcsr501_H #
include "stm32f10x.h" #include "sys.h" #define Hcsr501Port GPIOB #define
Hcsr501_Pin GPIO_Pin_4 #define Hcsr501IN PBin(5) extern u8 flag; //#define
EXIT_Disable EXTI->IMR &= ~(EXTI_Line1); // The specified external interrupt was turned off //#define EXIT_Enable
EXTI->IMR |= EXTI_Line1; // Turns on the specified external interrupt void Hcsr501_Init(void); #endif
nine , Demo

Technology