雾霾很严重
想买个PM2.5检测仪,网上一看都太贵,从400~8000。。。。。
然后查了查原理,很简单呀,就想做个PM2.5检测仪
晚上在网上逛了逛,发现了一个性价比很高的粉尘传感器,夏普的GP2Y1010AU0F
淘宝上卖27元,一下买了三个,做好了卖个试试,呵呵,加个有AD的单片机,一个锁存器,一个数显,成本应该50元之内
传感器PDF
下边的一些网上的资料
=====================================
使用夏普GP2Y1010AU0F灰尘传感器检测空气质量
夏普GP2Y1010AU0F灰尘传感器价格较便宜,能检测出室内空气中的灰尘和烟尘含量.
检测原理
其原理如下图,传感器中心有个洞可以让空气自由流过,定向发射LED光,通过检测经过空气中灰尘折射过后的光线来判断灰尘的含量。
根据电路图, 把Arduino和传感器连接起来:
- 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
- /*
- Interface to Sharp GP2Y1010AU0F Particle Sensor
- Program by Christopher Nafis
- Written April 2012
- http://www.sparkfun.com/datasheets/Sensors/gp2y1010au_e.pdf
- http://sensorapp.net/?p=479
- 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
- */
- #include<SPI.h>
- #include<stdlib.h>
- intdustPin=0;
- intledPower=2;
- intdelayTime=280;
- intdelayTime2=40;
- floatoffTime=9680;
- intdustVal=0;
- inti=0;
- floatppm=0;
- char s[32];
- floatvoltage=0;
- floatdustdensity=0;
- floatppmpercf=0;
- voidsetup(){
- Serial.begin(9600);
- pinMode(ledPower,OUTPUT);
- // give the ethernet module time to boot up:
- delay(1000);
- i=0;
- ppm=0;
- }
- voidloop(){
- 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/i*0.0049;
- dustdensity=0.17*voltage-0.1;
- ppmpercf=(voltage-0.0256)*120000;
- if(ppmpercf<0)
- ppmpercf=0;
- if(dustdensity<0)
- dustdensity=0;
- if(dustdensity>0.5)
- dustdensity=0.5;
- StringdataString=””;
- 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连接好后,可以连续打印出传感器的输出电压值。输出电压大小和灰尘含量的曲线入下图: