Arduino气体传感器-Sharp GP2Y10 空气质量传感器
Sharp GP2Y10传感器图片
Sharp GP2Y10传感器介绍
- 夏普光学粉尘传感器(gp2y1010au0f)是检测非常细小的颗粒,像香烟的烟雾效果,是常用的空气净化系统。
- 红外发光二极管和光敏三极管是对角布置的这个装置,让它来检测空气中的尘埃反射光。
- 该传感器具有非常低的电流消耗(20mA最大,典型,可11Ma)采用了7vdc。
- 该传感器的输出是模拟电压正比于测量粉尘浓度,具有灵敏度0.5v/0.1mg/m3。
Sharp GP2Y10传感器参数
- 工作电压: 5 ~ 7V
- 工作温度: -10 ~ 65摄氏度
- 最大电流: 20mA
Sharp GP2Y10传感器连接方式
Sensor Pin | Arduino Pin |
---|---|
Vled | 5V (150ohm resistor & 220uF capacitor) |
LED-GND | GND |
LED | Digital pin 2 |
S-GND | GND |
Vo | Analog pin 0 |
Vcc | 5V |
示例代码
/*
Standalone Sketch to use with a Arduino UNO and a
Sharp Optical Dust Sensor GP2Y1010AU0F
/**user define**/ int voutPin = A0;
//Connect Vo of dust sensor Vo to Arduino A0 pin int ledPin = 2;
//Connect LED(3pin) of dust sensor to Arduino D2 pin
*/
/**system define**/
int samplingTime = 280;
int deltaTime = 40;
int sleepTime = 9680;
int voMeasured = 0;
float calcVoltage = 0;
float dustDensity = 0;
void setup(){
Serial.begin(9600);
pinMode(ledPin,OUTPUT);
}
void loop(){
digitalWrite(ledPin,LOW); // power on the LED
delayMicroseconds(samplingTime);
voMeasured = analogRead(voutPin); // read the dust value
delayMicroseconds(deltaTime);
digitalWrite(ledPin,HIGH); // turn the LED off
delayMicroseconds(sleepTime);
// 0 - 5V mapped to 0 - 1023 integer values
// recover voltage
calcVoltage = (float)voMeasured * (5.0 / 1024.0);
// linear eqaution taken from http://www.howmuchsnow.com/arduino/airquality/
// Chris Nafis (c) 2012
if ( calcVoltage >= 0.6 )
{
dustDensity = 0.17 * calcVoltage - 0.1;
}
else
{
dustDensity = 0;
}
Serial.print("Raw Signal Value (0-1023): ");
Serial.print(voMeasured);
Serial.print(" - Voltage: ");
Serial.print(calcVoltage);
Serial.print("V");
Serial.print(" - Dust Density: ");
if( calcVoltage > 3.5 )
{
Serial.print(">"); // unit: mg/m3
}
Serial.print(dustDensity);
Serial.println(" mg/m3");
delay(1000);
}
获取最新文章: 扫一扫右上角的二维码加入“创客智造”公众号