Human Infrared Sensor
The human infrared sensor module uses a pyroelectric infrared sensor, which detects infrared radiation based on temperature changes. It employs a complementary method using two sensitive elements to suppress interference caused by temperature fluctuations, thereby improving the stability of the sensor's performance. This product has a wide range of applications, including security devices, anti-theft alarms, automatic doors, smart lighting, and intelligent toys.
Module Source
Purchase Link: https://item.taobao.com/item.htm?spm=a1z10.3-c-s.w4002-19589090137.18.2b9836b4sjtBQL&id=608680529121
Baidu Netdisk Download Link:
https://pan.baidu.com/s/1Bu0DL-1quXvY1Ede4c9ELw
Password: 8888
Specifications
Operating Voltage: 4.5~20V
Operating Current: <50uA
Output Level: High 3.3V / Low 0V Detection Angle: <100° cone angle
Output Method: GPIO
Pin Count: 3 Pins
Hardware Connection
HC-SR501 Human Motion Sensor Module Usage Instructions
- After powering on the sensor module, there is an initialization time of about one minute. During this period, the module will output 0 to 3 times at intervals. After one minute, it will enter standby mode.
- Avoid direct exposure of the module's lens surface to light sources like lamps to prevent interference signals that may cause false triggers. Try to avoid moving air, as wind can also interfere with the sensor's operation.
- The sensor module uses a dual-element probe with a rectangular window. The two elements (A and B) are located at the ends of the longer side of the window. When a person walks from left to right or right to left, the infrared radiation reaches the dual elements at different times and distances. The larger the difference, the more sensitive the detection. However, when a person walks directly towards the probe or from top to bottom or bottom to top, the dual elements cannot detect a change in the infrared spectrum distance, resulting in no difference and thus lower sensitivity or no response. Therefore, when installing the sensor, the direction of the dual-element probe should be as parallel as possible to the direction where human activity is most frequent, ensuring that the person is detected by both elements of the probe in sequence. To increase the sensing angle, this module uses a circular lens, which allows the probe to sense in all directions, but the left and right sides have a larger detection range than the top and bottom directions.
- Automatic Sensing: When a person enters the detection range, the module outputs a high level. When the person leaves the detection range, the module will automatically delay and then turn off the high level, outputting a low level.
- Two Triggering Modes (Selectable via Jumper):
Non-repetitive trigger mode: After the sensor outputs a high level, it will automatically switch to low level after the delay time ends; Repetitive trigger mode: After the sensor outputs a high level, if a human is detected within the sensing range during the delay period, the output will remain high until the person leaves, at which point the high level will be switched to low level after a delay.
- VCC: Connect to the 5V pin on the development board.
- OUT: Connect to the digital input pin 2 on the development board.
- GND: Connect to the GND pin on the development board.
Usage Method
int pirPin = 2; // 将PIR传感器的OUT引脚连接到数字引脚2
int pirState = LOW; // 初始化变量,没有检测到运动的情况下为LOW
void setup() {
pinMode(pirPin, INPUT); // 设置PIR传感器接口为输入
Serial.begin(9600); // 初始化串行通信
Serial.println("Waiting for sensor to stabilize");
delay(2000); // 给PIR传感器预热时间,稳定后再开始读取
}
void loop() {
int val = digitalRead(pirPin); // 读取PIR传感器的状态
if (val == HIGH) { // 检查是否检测到运动
if (pirState == LOW) {
// 我们有一个运动信号!
Serial.println("Motion detected!");
pirState = HIGH; // 更新变量状态,表示已检测到运动
}
} else {
if (pirState == HIGH) {
// 动作已停止
Serial.println("Motion ended!");
pirState = LOW; // 更新变量状态,表示运动已停止
}
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
Usage Testing
It can detect movements around it and automatically recover after a period of time.