使用夏普GP2Y1010AU0F灰尘传感器检测空气质量
微雪Dust Sensor 用户手册说明书

Dust Sensor灰尘传感器用户手册1.特性和原理本模块是以夏普GP2Y1010AU0F为核心的灰尘传感器。
传感器内部的红外二极管,可以输出一个跟灰尘浓度成线性关系的电压值。
通过该电压值即可计算出空气中的灰尘和烟尘含量。
测量对象:直径大于0.8μm灰尘颗粒有效量程:500μg/m3输出类型:电压模拟量工作电压: 2.5V~5.5V产品尺寸:63.2mm×41.3mm固定孔尺寸: 2.0mm通气孔尺寸:9.0mm1.1.传感器输出特性传感器输出电压与灰尘浓度关系在0到0.5mg/m3范围内成线性关系,如下图所示:图1: 传感器输出特性曲线1.2.传感器控制原理1)通过设置模块I LED引脚为高电平,从而打开传感器内部红外二极管。
2)等待0.28ms,外部控制器采样模块A OUT引脚的电压值。
这是因为传感器内部红外二极管在开启之后0.28ms,输出波形才达到稳定。
如下图所示:图2: I LED与红外二极管输出波形关系3)采样持续0.04ms之后,再设置I LED引脚为低电平,从而关闭内部红外二极管。
4)根据电压与浓度关系即可计算出当前空气中的灰尘浓度,具体实现细节请参考Demo程序。
注:输出的电压经过了分压处理(查看原理图),要将测得的电源放大11倍才是实际传感器输出的电压。
1.3.主要用途检测空气中灰尘浓度,用于空气净化器、空气质量监测仪、PM2.5检测仪等。
2.操作和现象2.1.传感器接口说明表1: 传感器接口说明2.2.连接开发板使用下面章节以四款不同类型的开发板为例,描述具体操作步骤及实验现象。
2.2.1.Open103R(主控芯片STM32F103R)1)编译下载Demo程序。
2)3)表2: 传感器和Open103R引脚对应关系4)开发板上电,可看到串口助手不断显示当前灰尘浓度值,当有大量灰尘颗粒进入通气孔时,数据发生明显变化,实验现象见附录。
2.2.2.Open407Z-C(主控芯片STM32F407Z)1)编译下载Demo程序。
基于stm32单片机的空气净化器设计

基于stm32单片机的空气净化器设计一、系统总体设计本空气净化器主要由传感器模块、风机模块、净化模块、控制模块和显示模块组成。
传感器模块用于检测空气中的污染物浓度,如 PM25、甲醛、TVOC 等。
常见的传感器有激光粉尘传感器、电化学甲醛传感器等。
这些传感器将检测到的数据传输给控制模块。
风机模块负责驱动空气流动,使空气经过净化模块进行净化处理。
风机的转速可以根据空气质量的好坏进行调节,以达到节能和高效净化的目的。
净化模块是空气净化器的核心部分,通常采用多层滤网结构,包括初效滤网、高效滤网(HEPA 滤网)、活性炭滤网等。
初效滤网主要过滤大颗粒灰尘,高效滤网能有效去除微小颗粒物,活性炭滤网则用于吸附甲醛、TVOC 等有害气体。
控制模块采用 stm32 单片机作为核心处理器,接收传感器模块传来的数据,并根据预设的算法控制风机模块和净化模块的工作状态。
同时,还负责与显示模块进行通信,将空气质量信息和设备工作状态显示出来。
显示模块一般采用液晶显示屏(LCD)或触摸屏,向用户直观地展示空气质量指标、工作模式、风速等信息,方便用户操作和了解设备运行情况。
二、硬件设计1、传感器选型与接口设计选择精度高、响应速度快的传感器。
例如,选用夏普的GP2Y1010AU0F 粉尘传感器来检测 PM25 浓度,其输出为模拟电压信号,通过 ADC 转换后输入到 stm32 单片机。
对于甲醛和 TVOC 检测,采用 ZE08-CH2O 电化学传感器,其输出为数字信号,通过 UART 接口与单片机通信。
2、风机驱动电路设计选用无刷直流电机作为风机,通过 MOSFET 管组成的 H 桥电路进行驱动。
stm32 单片机输出的PWM 信号控制MOSFET 的导通与截止,从而实现风机转速的调节。
3、净化模块电路设计净化模块中的滤网需要定期更换,通过在滤网上安装检测装置,将滤网的使用情况反馈给单片机,当滤网达到使用寿命时,通过显示模块提醒用户更换。
基于单片机的智能空气净化系统

2019年9月第19卷第3期廊坊师范学院学报(自然科学版)Journal of Langfang Normal University (Natural Science Edition)Sep.2019Vol.19 No.3基于单片机的智能空气净化系统郑安豫,杨胜春,李红祥,房雁平(安徽电气工程职业技术学院,安徽合肥230051)【摘要】设计了一种基于单片机的智能空气净化系统。
通过传感器实时采集空气中PM2.5、甲醛等有害健康物质的浓度,将各项数据显示到液晶显示屏,当浓度超过设置的警戒值时,控制蜂鸣器发出警报。
根据浓度大小控制空气净化 器电机转速,实现空气净化器的智能控制,空气质量差时,实现快速空气净化;空气质量好时,能省电降低噪音。
实验表 明,该系统对清除室内空气污染物质、提高室内空气质量有良好的效果。
【关键词】单片机;空气净化;传感器A Design of Intelligent Air Purifier System Based on MCUZHENG An-yu, YANG Sheng-chun, LI Hong-xiang, FANG Yan-ping(Anhui Electrical Engineering Professional Technique College, Hefei 230051, China)[Abstract] An smart air purification system based on 51 single chip computer is designed. The concentration of PM2.5,fbimaldehyde and other harmful health substances in the air is collected by sensors in real time, and the data are displayedon the LCD screen. When the concentration exceeds the standard, the buzzer is controlled to give an alarm. According to theconcentration, the motor speed of air purifier is controlled. When the air quality is poor, the rapid air purification is achieved.When the air quality is good, the power saving and noise reduction are achieved.[Key words] MCU; air purification; sensor冲图分类号〕TP212.9〔文献标识码〕A 〔文章编号〕1674 - 3229(20⑼03- 0039 - 030 引言随着生活水平的提高,人们对生活环境舒适度的要求也随之提高,室内装修也越来越精致。
使用夏普GP2Y1010AU0F灰尘传感器检测空气质量..

使用夏普GP2Y1010AU0F灰尘传感器检测空气质量夏普灰尘传感器价格较便宜,能检测出室内空气中的灰尘和烟尘含量.检测原理其原理如下图,传感器中心有个洞可以让空气自由流过,定向发射LED光,通过检测经过空气中灰尘折射过后的光线来判断灰尘的含量。
电路图因为数据是通过pin 5的电压模拟信号输出的,而树莓派的引脚不支持模拟信号直接读取(需要增加数模转换芯片),所以先用Arduino来实验。
Arduino 代码根据电路图,把Arduino和传感器连接起来:1.Sharp pin 1 (V-LED) => 5V 串联1个150欧姆的电阻(最好在电阻一侧和GND之间再串联一个220uf的电容)2.Sharp pin 2 (LED-GND) => GND3.Sharp pin 3 (LED) => Arduino PIN 2 (开关LED)4.Sharp pin 4 (S-GND) => GND5.Sharp pin 5 (Vo) => Arduino A0 pin (空气质量数据通过电压模拟信号输出)6.Sharp pin 6 (Vcc) => 5V1./*2.Interface to Sharp GP2Y1010AU0F Particle Sensor3.Program by Christopher Nafis4.Written April 20125.6.7.8.9.Sharp pin 1 (V-LED) => 5V (connected to 150ohm resister)10.Sharp pin 2 (LED-GND) => Arduino GND pin11.Sharp pin 3 (LED) => Arduino pin 212.Sharp pin 4 (S-GND) => Arduino GND pin13.Sharp pin 5 (Vo) => Arduino A0 pin14.Sharp pin 6 (Vcc) => 5V15.*/16.#include<SPI.h>17.#include<stdlib.h>18.19.int dustPin=0;20.int ledPower=2;21.int delayTime=280;22.int delayTime2=40;23.float offTime=9680;24.25.int dustVal=0;26.int i=0;27.float ppm=0;28.char s[32];29.float voltage=0;30.float dustdensity=0;31.float ppmpercf=0;32.33.void setup(){34.Serial.begin(9600);35. pinMode(ledPower,OUTPUT);36.37.// give the ethernet module time to boot up:38. delay(1000);39.40. i=0;41. ppm=0;42.}43.44.void loop(){45. i=i+1;46. digitalWrite(ledPower,LOW);// power on the LED47. delayMicroseconds(delayTime);48. dustVal=analogRead(dustPin);// read the dust value49. ppm=ppm+dustVal;50. delayMicroseconds(delayTime2);51. digitalWrite(ledPower,HIGH);// turn the LED off52. delayMicroseconds(offTime);53.54. voltage=ppm/i*0.0049;55. dustdensity=0.17*voltage-0.1;56. ppmpercf=(voltage-0.0256)*120000;57.if(ppmpercf<0)58. ppmpercf=0;59.if(dustdensity<0)60. dustdensity=0;61.if(dustdensity>0.5)62. dustdensity=0.5;63.String dataString="";64. dataString+=dtostrf(voltage,9,4,s);65. dataString+=",";66. dataString+=dtostrf(dustdensity,5,2,s);67. dataString+=",";68. dataString+=dtostrf(ppmpercf,8,0,s);69. i=0;70. ppm=0;71.Serial.println(dataString);72. delay(1000);73.}把传感器和Ardiuno连接好后,可以连续打印出传感器的输出电压值。
夏普原版灰尘传感器gp2y1010au规格书

GP2Y1010AU0FGP2Y1010AU0FCompact Optical Dust Sensor■Description■Features■Compliance■Applications1. Detecting of dust in the air.2. Example: Air purifier, Air conditioner, Air monitor1. Compliant with RoHS directive (2002/95/EC)1. Compact, thin package (46.0 × 30.0 × 17.6 mm)2. Low consumption current (Icc: MAX. 20 mA)3. The presence of dust can be detected by the photometry of only one pulse4. Enable to distinguish smoke from house dust5. Lead-free and RoHS directive compliantNotice The content of data sheet is subject to change without prior notice.In the absence of confirmation by device specification sheets, SHARP takes no responsibility for any defects that may occur in equipment using any SHARP devices shown in catalogs, data books, etc. Contact SHARP in order to obtain the latest device specification sheets before using any SHARP device.GP2Y1010AU0F is a dust sensor by optical sensing system.An infrared emitting diode (IRED) and an phototran-sistor are diagonally arranged into this device.It detects the reflected light of dust in air.Especially, it is effective to detect very fine particle like the cigarette smoke.In addition it can distinguish smoke from house dust by pulse pattern of output voltage.■Internal schematic■Outline Dimensions(Unit : mm)V-LEDLED-GND LED S-GND V O V CC123456132654Marking informationDate code (2 digit)1st digit2nd digitYear of production Month of productionA.D.Mark Month Mark2000011200112220022332003344200445520055662006677200778820088992009910X2010011Y::12Z repeats in a 10 year cycleCountry of originPhilippines■■ Absolute Maximum Ratings*1 Open drain drive inputParameter Symbol Rating Unit Supply voltageCC V Operating temperature T T opr −10 to +65°C −0.3 to V CC V −0.3 to +7Input terminal voltage V V LED *1Soldering temperaturesol−20 to +80°CElectro-optical Characteristics■ Recommended input condition for LED input terminalParameter ConditionsSymbol K V OC I LED *1 *2 *3*2 *3*2 *3R L =4.7k Ω*2LED terminal voltage = 0*2R L =∞MIN.0.3503.4−−TYP.0.50.9−1110MAX.1.50.65−2020Unit V/(0.1mg/m 3)V V mA mASensitivityOutput voltage at no dust V OH Output voltage range LED terminal current I CCConsumption current*1 Sensitivity is specified by the amount of output voltage change when dust density changes by 0.1 mg/m 3.And the dust density for detection is a value of the density of cigarette (MILD SEVEN®) smoke measured by the digital dust monitor (P-5L2: manufactured by SHIBATA SCIENTIFIC TECHNOLOGY LTD.).*2 Input condition is shown in Fig. 1*3 Output sampling timing is shown in Fig. 2(T a =25°C)(T a =25°C, V CC =5V)ParameterPulse Cycle Pulse WidthOperating Supply voltageSymbol T P W V CCValue 10 ± 10.32 ± 0.025 ± 0.5Unit ms ms VFig. 1 Input Condition for LED Input TerminalFig. 2 Sampling Timing of Output PulseI LEDRemarks : Please be aware that all data in the graph are just for reference and are not for guarantee.432100.20.40.60.8O u t p u t v o l t a g e (V )Dust density (mg/m 3)Fig. 3 Output Voltage vs. Dust Density●Notes1 Connection of case and GNDCase material use conductive resin as cover case {printed model No.} and metal {test terminal side}as bottom cover. The metal case connects with GND in sensor.2 CleaningPlease don’t do cleaning, because there is a case that this device is not satisfied with its characteristics by cleaning.3 Pulse input rangePlease subject to recommendation as regard input condition for LED in order to keep reliability.4 Dust adhesionThere is a case that this product does not detect the dust density correctly, since the dust adhered to the inside of the dust through hole may project into the detecting space which consist of emitter anddetector light axis. Please take the structure and mechanism of the equipment into consideration toavoid the influence of adhered dust. And when the dust is adhered, please consider the maintenance such as vacuuming or blowing off the dust by air.In addition, please pay attention to structure and placing location of the application to avoid anyadhesive particle like oil, etc. to gets into the device. If it sticks to optical part, malfunction may occur.5 Light outputIn circuit designing, make allowance for the degradation of the light emitting diode output that resultsfrom long continuous operation. (50% degradation/5 years)6 Sensitivity adjustment VRVR for sensitivity adjustment is set up at shipping from sharp. Please do not touch the VR orElectro-optical characteristics specified on the specification will be invalid.7 ResolutionPlease do not disassemble the device such as removing tapping screw and so on. Even if the device is reassembled, it may not satisfy the specification.8 Application to fire alarmPlease do not use this device for a fire alarm application. When using this device to application other than air purifying and equipment with air purifying function, please inform us before usage.9 Noise influenceIf the sensor is located close to noise generator (ex. Electric dust collector, etc. ), the sensor outputmay be affected by leaded noise. On top of that noise from power supply line also may affect thesensor output. When desinging the system, please consider the effect from noise.10 Vibration influenceThe sensor may change its value under mechanical oscillation. Before usage, please make surethat the device works normally in the application.11 Incident light influenceThere is a case that the sensor output may be affected when outer-light comes through dust through hole on printed side. In order to avoid any influence from outer-light, please locate the printed sideof sensor facing to inside of the application.12 When inside of the sensor is moisturized, this product does not keep its proper function. Pleasedesign the application so that moisturization of the sensor does not happen.Sheet No.: E4-A01501EN●Presence of ODC etc.This product shall not contain the following materials.And they are not used in the production process for this product.Regulation substances : CFCs, Halon, Carbon tetrachloride, 1.1.1-Trichloroethane (Methylchloroform) Specific brominated flame retardants such as the PBB and PBDE are not used in this product at all.This product shall not contain the following materials banned in the RoHS Directive (2002/95/EC).• Lead, Mercury, Cadmium, Hexavalent chromium, Polybrominated biphenyls (PBB),Polybrominated diphenyl ethers (PBDE).Packing SpecificationPACKING METHOD1. Each tray holds 50 pieces. Packing methods are shown in (A).2. Each box holds 5 trays. Pads are added to top (B).3. The box is sealed with packing tape. (C) shows the location of the Model number, Quantity, and Inspection date.4. Weight is approximately5.6 kg■Important Notices· The circuit application examples in this publication are provided to explain representative applications of SHARP devices and are not intended to guarantee any circuit design or license any intellectual property rights. SHARP takes no responsibility for any problems related to any intellectual property right of a third party resulting from the use of SHARP's devices.· Contact SHARP in order to obtain the latest device specification sheets before using any SHARP device. SHARP reserves the right to make changes in the spec- ifications, characteristics, data, materials, structure, and other contents described herein at any time without no-tice in order to improve design or reliability. Manufactur-ing locations are also subject to change without notice.· Observe the following points when using any devices in this publication. SHARP takes no responsibility for damage caused by improper use of the devices which does not meet the conditions and absolute maximum ratings to be used specified in the relevant specification sheet nor meet the following conditions:(i) The devices in this publication are designed for use in general electronic equipment designs such as:--- Personal computers--- Office automation equipment--- Telecommunication equipment [terminal]--- Test and measurement equipment--- Industrial control--- Audio visual equipment--- Consumer electronics(ii) Measures such as fail-safe function and redundant design should be taken to ensure reliability and safety when SHARP devices are used for or in connection with equipment that requires higher reliability such as:--- Transportation control and safety equipment (i.e., aircraft, trains, automobiles, etc. )--- Traffic signals--- Gas leakage sensor breakers--- Alarm equipment--- Various safety devices, etc.(iii) SHARP devices shall not be used for or in connec-tion with equipment that requires an extremely high level of reliability and safety such as:--- Space applications--- Telecommunication equipment [trunk lines]--- Nuclear power control equipment--- Medical and other life support equipment (e.g., scuba).· If the SHARP devices listed in this publication fall within the scope of strategic products described in the Foreign Exchange and Foreign Trade Law of Japan, it is necessary to obtain approval to export such SHARP devices.· This publication is the proprietary product of SHARP and is copyrighted, with all rights reserved. Under the copyright laws, no part of this publication may be re-produced or transmitted in any form or by any means, electronic or mechanical, for any purpose, in whole or in part, without the express written permission of SHARP. Express written permission is also required before any use of this publication may be made by a third party.· Contact and consult with a SHARP representative if there are any questions about the contents of this publi-cation.Sheet No.: E4-A01501EN。
基于51单片机下的空气质量测试仪

《基于51单片机下的空气质量测试仪》的文献综述项目名称:基于51单片机下的空气质量测试仪项目负责人:杨宽(学号:16012311)项目参加者:白名章(学号:16012312)姚宇(学号:16012628)许珊(学号:16012306)项目指导老师:潘石(所属院系:电气工程学院)一.背景介绍工农业的快速发展使得人们物质生活水平得到前所未有的快速提高,但是随之而来的空气污染问题却愈加严重。
世界银行发布的报告表明,由空气污染导致的过早死亡人数,平均为每天1000人,也就是每年有35至40万的人面临着死亡。
近年来,随着一连串有关空气质量问题的事件的发生,人们对空气污染问题愈加地担忧,对创建绿色健康的生活环境的呼声也日益高涨。
中国环境监测总站2012年5月下发的《PM2.5自动监测仪器技术指标与要求(试行)》确定了三种PM2.5的自动监测方法,分别是β射线方法仪器加装动态加热系统,β射线方法仪器加动态加热系统联用光散射法,微量振荡天平方法仪器加膜动态测量系统。
这些方法固然准确,但是我们只能通过媒体查询获得关于较大范围内,比如整个城市内的空气质量指数,却不能实时地监测身边的尤其是室内的空气质量,从而不能及时注意到身边的空气质量变化,安全健康的生活环境便不能得到有效的保障。
所以,有必要设计一种便携式的用于室内空气质量监测的设备,通过检测设备显示的空气质量的级别高低使用户对室内空气质量有一个定性和定量的了解,为人们拥有一个舒适健康的生活环境提供保障。
二.国内外空气质量检测研究现状在空气质量监测方面,国外做的比较好的有:美国Interscan科技有限公司生产的4000型空气质量分析仪,英国PPM公司生产的PPM-400甲醛检测仪;国内的有:邯郸派瑞气体设备有限公司研制的“派瑞”系列空气健康表,江西南昌贝谷科技股份有限公司生产的“甲保御”牌室内环境污染标定仪等。
但是,目前国内的产品较之国外的产品在功能的完备度,检测精度以及用户体验等方面还有一定的差距,国外产品的功能比较完备,测量精度高,系统交互界面相对人性化,因此价格比较高。
夏普灰尘传感器原理

夏普灰尘传感器原理夏普灰尘传感器是一种常用于空气质量监测的传感器,可以通过测量空气中的灰尘浓度,判断空气的污染程度。
它是基于光学原理工作的,通过测量光的散射来间接测量空气中的灰尘颗粒数量。
夏普灰尘传感器的原理是利用散射光的特性来测量灰尘浓度。
当光线照射到灰尘粒子上时,由于灰尘粒子的形状和大小不同,光线会发生不同程度的散射。
传感器中的激光二极管发射出一束单色激光,该激光经过准直透镜和散射板,形成一束平行光。
当光线遇到空气中的灰尘粒子时,部分光线会被散射到散射板上的光敏电阻。
散射到散射板上的光线,会被光敏电阻转化为电信号。
夏普灰尘传感器采用了光敏电阻的电阻值与光强成反比的原理。
当光敏电阻接收到较少的光线时,电阻值较高,电流较小;当光敏电阻接收到较多的光线时,电阻值较低,电流较大。
通过测量光敏电阻的电流大小,就可以得到空气中灰尘的浓度。
为了避免其他因素干扰,夏普灰尘传感器采用了光路双光子法。
传感器中设置两个光敏二极管,其中一个光敏二极管用来检测散射光的强度,另一个光敏二极管用来检测透射光的强度。
透射光是指光线通过空气中没有灰尘的部分,达到另一侧光敏二极管上。
通过对比散射光和透射光的强度差异,可以消除其他因素对灰尘浓度测量的影响,提高测量的准确性。
夏普灰尘传感器还通过在光路中加入一个专用滤光片来选择测量特定粒径的灰尘颗粒。
这个滤光片只允许特定波长的光线通过,其他波长的光线则会被滤除。
通过选择适当的滤光片,可以使传感器只测量某一特定粒径的灰尘颗粒,排除其他尺寸颗粒的干扰。
综上所述,夏普灰尘传感器是通过测量光线的散射来间接测量空气中的灰尘浓度。
传感器采用了散射光和透射光之间的差异,以及滤光片的选择,来消除其他因素对测量结果的影响。
这种原理使得夏普灰尘传感器在空气质量监测领域具有较高的准确性和可靠性。
夏普GP2Y1010AU0F_粉尘传感器参考程序

夏普GP2Y1010AU0F_粉尘传感器参考程序简介:Sharp's GP2Y1010AU0F 是一款光学空气质量传感器,设计用来感应空气中的尘埃粒子,其内部对角安放着红外线发光二极管和光电晶体管,使得其能够探测到空气中尘埃反射光,即使非常细小的如烟草烟雾颗粒也能够被检测到,通常在空气净化系统中应用。
该传感器具有非常低的电流消耗(最大20mA,典型值11mA),可使用高达7VDC。
该传感器输出为模拟电压,其值与粉尘浓度成正比。
可测量0.8微米以上的微笑粒子,感知烟草产生的咽气和花粉,房屋粉尘等.体积小,重量轻,便于安装,广泛应用于空气清新机,换气空调,换气扇等产品.灵敏度:0.5V/0.1mg/m3尺寸:46.0 × 30.0 × 17.6 mm)Do not miss the 150ohm resistor and a 220uF capacitorSensor Pin Arduino Pin1Vled–>5V (150ohmresistor)2LED-GND–>GND3LED–>Digital pin 24S-GND–>GND5Vo–>Analog pin 06Vcc–>5VThe LED pin has to be modulated with a cycle of 1ms as discussed in the datasheet.The LED seems to use a PNP transistor so to power on, the LED pin must actually recieve a lower voltage.例程;int dustPin=0;int dustVal=0;int ledPower=2;int delayTime=280;int delayTime2=40;float offTime=9680;void setup(){Serial.begin(9600);pinMode(ledPower,OUTPUT);pinMode(4, OUTPUT);}void loop(){// ledPower is any digital pin on the arduino connected to Pin 3 on the sensordigitalWrite(ledPower,LOW); // power on the LED delayMicroseconds(delayTime);dustVal=analogRead(dustPin); // read the dust value via pin 5 on the sensordelayMicroseconds(delayTime2);digitalWrite(ledPower,HIGH); // turn the LED off delayMicroseconds(offTime);delay(3000);Serial.println(dustVal);}。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
使用夏普GP2Y1010AU0F灰尘传感器检测空气质量
夏普灰尘传感器价格较便宜,能检测出室内空气中的灰尘和烟尘含量.
检测原理
其原理如下图,传感器中心有个洞可以让空气自由流过,定向发射LED光,通过检测经过空气中灰尘折射过后的光线来判断灰尘的含量。
电路图
因为数据是通过pin 5的电压模拟信号输出的,而树莓派的引脚不支持模拟信号直接读取(需要增加数模转换芯片),所以先用Arduino来实验。
Arduino 代码
根据电路图,把Arduino和传感器连接起来:
1.Sharp pin 1 (V-LED) => 5V 串联1个150欧姆的电阻(最好在电阻一侧和GND之间再串联一个
220uf的电容)
2.Sharp pin 2 (LED-GND) => GND
3.Sharp pin 3 (LED) => Arduino PIN 2 (开关LED)
4.Sharp pin 4 (S-GND) => GND
5.Sharp pin 5 (Vo) => Arduino A0 pin (空气质量数据通过电压模拟信号输出)
6.Sharp pin 6 (Vcc) => 5V
1./*
2.Interface to Sharp GP2Y1010AU0F Particle Sensor
3.Program by Christopher Nafis
4.Written April 2012
5.
6./pic//datasheets/Sensors/gp2y1010au_e.pdf
7./pic//?p=479
8.
9.Sharp pin 1 (V-LED) => 5V (connected to 150ohm resister)
10.Sharp pin 2 (LED-GND) => Arduino GND pin
11.Sharp pin 3 (LED) => Arduino pin 2
12.Sharp pin 4 (S-GND) => Arduino GND pin
13.Sharp pin 5 (Vo) => Arduino A0 pin
14.Sharp pin 6 (Vcc) => 5V
15.*/
16.#include<SPI.h>
17.#include<stdlib.h>
18.
19.int dustPin=0;
20.int ledPower=2;
21.int delayTime=280;
22.int delayTime2=40;
23.float offTime=9680;
24.
25.int dustVal=0;
26.int i=0;
27.float ppm=0;
28.char s[32];
29.float voltage=0;
30.float dustdensity=0;
31.float ppmpercf=0;
32.
33.void setup(){
34.Serial.begin(9600);
35. pinMode(ledPower,OUTPUT);
36.
37.// give the ethernet module time to boot up:
38. delay(1000);
39.
40. i=0;
41. ppm=0;
42.}
43.
44.void loop(){
45. i=i+1;
46. digitalWrite(ledPower,LOW);// power on the LED
47. delayMicroseconds(delayTime);
48. dustVal=analogRead(dustPin);// read the dust value
49. ppm=ppm+dustVal;
50. delayMicroseconds(delayTime2);
51. digitalWrite(ledPower,HIGH);// turn the LED off
52. delayMicroseconds(offTime);
53.
54. voltage=ppm/i*0.0049;
55. dustdensity=0.17*voltage-0.1;
56. ppmpercf=(voltage-0.0256)*120000;
57.if(ppmpercf<0)
58. ppmpercf=0;
59.if(dustdensity<0)
60. dustdensity=0;
61.if(dustdensity>0.5)
62. dustdensity=0.5;
63.String dataString="";
64. dataString+=dtostrf(voltage,9,4,s);
65. dataString+=",";
66. dataString+=dtostrf(dustdensity,5,2,s);
67. dataString+=",";
68. dataString+=dtostrf(ppmpercf,8,0,s);
69. i=0;
70. ppm=0;
71.Serial.println(dataString);
72. delay(1000);
73.}
把传感器和Ardiuno连接好后,可以连续打印出传感器的输出电压值。
输出电压大小和灰尘含量的曲线入下图:
通过电压的波形还可以判断是烟还是尘呢…。