【Arduino基础教程】PM2.5粉尘检测传感器

作者: 繁著 | 来源:发表于2016-06-24 17:53 被阅读1233次
GP2Y1010AU0F Arduino
1 150欧电阻 5V
1 220uF电解电容 GND
2 -> GND
3 -> 2
4 -> GND
5 -> A0
6 -> 5V

示例程序

int dustPin=0;
float dustVal=0;
int ledPower=2;
int delayTime=280;
int delayTime2=40;
float offTime=9680;
void setup(){
  Serial.begin(9600);
  pinMode(ledPower,OUTPUT);
  pinMode(dustPin, INPUT);
}
 
void loop(){
// ledPower is any digital pin on the arduino connected to Pin 3 on the sensor
  digitalWrite(ledPower,LOW); 
  delayMicroseconds(delayTime);
  dustVal=analogRead(dustPin); 
  delayMicroseconds(delayTime2);
  digitalWrite(ledPower,HIGH); 
  delayMicroseconds(offTime);
  delay(1000);
  if (dustVal>36.455)
    Serial.println((float(dustVal/1024)-0.0356)*120000*0.035);
}

附:测试得到的数据和空气质量对照:

3000 + = 很差
1050-3000 = 差
300-1050 = 一般
150-300 = 好
75-150 = 很好
0-75 = 非常好

相关文章

网友评论

    本文标题:【Arduino基础教程】PM2.5粉尘检测传感器

    本文链接:https://www.haomeiwen.com/subject/jmgodttx.html