GP2Y1014AU Dust Sensor
The GP2Y1014AU dust sensor has a hole in the center that allows air to flow freely. Inside the sensor, an infrared light-emitting diode (LED) and a phototransistor are installed at adjacent positions. The infrared LED emits directional infrared light, and when particles in the air obstruct the infrared light, it undergoes diffuse reflection. The phototransistor receives the reflected infrared light, causing a change in the voltage at the signal output pin. This voltage value is linearly related to the dust concentration within a certain range. Therefore, during use, the ADC should be used to collect this voltage signal, and the dust concentration in the air can be calculated based on this voltage value.
Module Source
Specifications
Operating Voltage: 5-7V
Current Consumption: Maximum 20mA
Minimum Particle Detection Size: 0.8 microns
Sensitivity: 0.5V (0.1mg/m³)
Voltage in Clean Air: 0.9V (typical)
Weight: 15g
Dimensions: 46x30x17.6mm
Hardware Connection
Connect the GP2Y1014AU pins to the development board as follows:
GP2Y1014AU Pin -> ColorEasyDuino Pin
1 (V-LED) -> 5V
2 (LED-GND) -> GND
3 (LED) -> 2
4 (S-GND) -> GND
5 (Vo) -> A0
6 (Vcc) -> 5V
2
3
4
5
6
7
Usage Method
/******************************************************************************
* Test Hardware: LCSC ColorEasyDuino Development Board
* Version Number: V1.0
* Modified By: www.lckfb.com
* Modification Date: April 11, 2024
* Function Overview:
*****************************************************************************
* Open-source development board hardware and software information and related projects hardware and software information on official website
* Development board official website: www.lckfb.com
* Technical support resident forum, any technical problems are welcome at any time to exchange learning
* LCSC Forum: club.szlcsc.com
* Follow our Bilibili account: [立创开发板], stay toned to our latest news!
* We focus on cultivating Chinese engineers rather than profiting from board sales.
******************************************************************************/
// 定义GP2Y1014AU的引脚
const int ledPower = 2; // LED驱动引脚
const int measurePin = A0; // 模拟测量引脚
// 测量参数和定时器
unsigned long duration;
unsigned long starttime;
unsigned long sampletime_ms = 30000; // 测量周期为30秒
unsigned long lowpulseoccupancy = 0;
float ratio = 0;
float concentration = 0;
void setup() {
Serial.begin(9600);
pinMode(ledPower, OUTPUT);
digitalWrite(ledPower, LOW); // 低电平以确保LED不会亮起直到程序开始
starttime = millis(); // 获取当前时间
}
void loop() {
// 打开传感器LED
digitalWrite(ledPower, HIGH);
delayMicroseconds(280); // LED打开的时间
duration = pulseIn(measurePin, LOW); // 测量低电平持续的时间
delayMicroseconds(40); // 测量持续时间
digitalWrite(ledPower, LOW); // 关闭LED
lowpulseoccupancy += duration; // 累积低电平持续时间
// 测量周期结束后计算粉尘浓度
if ((millis()-starttime) > sampletime_ms) {
ratio = lowpulseoccupancy / (sampletime_ms * 10.0); // 低电平占空比
concentration = 1.1 * pow(ratio, 3) - 3.8 * pow(ratio, 2) + 520 * ratio + 0.62; // 使用夏普提供的计算公式
Serial.print("浓度: ");
Serial.print(concentration);
Serial.print(" pcs/0.01cf\n");
lowpulseoccupancy = 0;
starttime = millis();
}
}
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56