夏普GP2Y1010AU0F灰尘传感器价格较便宜,能检测出室内空气中的灰尘和烟尘含量。另外还有韩国SYHITECH生产的DSM501A粉尘传感器也有类似功能。
技术参数
- 电源电压:5-7V
- 工作温度:-10-65摄氏度
- 消耗电流:20mA最大
硬件连接
- Sharp pin 1 (V-LED) => 5V 串联1个150欧姆的电阻(最好在电阻一侧和GND之间再串联一个220uf的电容)
- Sharp pin 2 (LED-GND) => GND
- Sharp pin 3 (LED) => Arduino PIN 2 (开关LED)
- Sharp pin 4 (S-GND) => GND
- Sharp pin 5 (Vo) => Arduino A0 pin (空气质量数据通过电压模拟信号输出)
- Sharp pin 6 (Vcc) => 5V
LED引脚必须调节成1ms的周期,这点在数据表中讨论过。 LED似乎使用的是PNP晶体管来通电,LED引脚必须接收一个较低的电压。
/* Interface to Sharp GP2Y1010AU0F Particle Sensor
Sharp pin 1 (V-LED) => 5V (connected to 150ohm resister)
Sharp pin 2 (LED-GND) => Arduino GND pin
Sharp pin 3 (LED) => Arduino pin 2
Sharp pin 4 (S-GND) => Arduino GND pin
Sharp pin 5 (Vo) => Arduino A0 pin
Sharp pin 6 (Vcc) => 5V
*/
int dustPin=0;
int ledPower=2;
int delayTime=280;
int delayTime2=40;
float offTime=9680;
int dustVal=0;
int i=0;
float ppm=0;
char s[32];
float voltage = 0;
float dustdensity = 0;
float ppmpercf = 0;
void setup() {
Serial.begin(9600);
pinMode(ledPower,OUTPUT);
delay(1000); //@Waiting for bootup
i=0;
ppm =0;
}
void loop() {
i=i+1;
digitalWrite(ledPower,LOW); // power on the LED
delayMicroseconds(delayTime);
dustVal=analogRead(dustPin); // read the dust value
ppm = ppm+dustVal;
delayMicroseconds(delayTime2);
digitalWrite(ledPower,HIGH); // turn the LED off
delayMicroseconds(offTime);
voltage = ppm/i0.0049;
dustdensity = 0.17voltage-0.1;
ppmpercf = (voltage-0.0256)*120000;
if (ppmpercf < 0) ppmpercf = 0;
if (dustdensity < 0 ) dustdensity = 0;
if (dustdensity > 0.5) dustdensity = 0.5;
String dataString = "";
dataString += dtostrf(voltage, 9, 4, s);
dataString += ",";
dataString += dtostrf(dustdensity, 5, 2, s);
dataString += ",";
dataString += dtostrf(ppmpercf, 8, 0, s);
i=0;
ppm=0;
Serial.println(dataString);
delay(1000);
}
结果分析
把传感器和 Ardiuno 连接好后,可以连续打印出传感器的输出电压值。输出电压大小和灰尘含量的曲线入下图:
通过电压的波形还可以判断是烟还是尘