只需一步,快速开始
签到天数: 63 天
[LV.6]常住居民II
粉尘传感器原理图.jpg (48.09 KB, 下载次数: 40)
下载附件
2015-7-28 10:17 上传
灰尘传感器2.jpg (48.47 KB, 下载次数: 53)
2015-7-28 10:14 上传
int pin = 8; unsigned long duration; unsigned long starttime; unsigned long sampletime_ms = 30000;//sampe 30s ; unsigned long lowpulseoccupancy = 0; float ratio = 0; float concentration = 0; void setup() { Serial.begin(9600); pinMode(8,INPUT); starttime = millis();//get the current time; } void loop() { duration = pulseIn(pin, LOW); lowpulseoccupancy = lowpulseoccupancy+duration; if ((millis()-starttime) > sampletime_ms)//if the sampel time == 30s { ratio = lowpulseoccupancy/(sampletime_ms*10.0); // Integer percentage 0=>100 concentration = 1.1*pow(ratio,3)-3.8*pow(ratio,2)+520*ratio+0.62; // using spec sheet curve Serial.print(lowpulseoccupancy); Serial.print("concentration = "); Serial.print(concentration); Serial.println(" pcs/0.01cf"); Serial.println("\n"); lowpulseoccupancy = 0; starttime = millis(); } }
时间百分比与浓度关系.png (43.68 KB, 下载次数: 51)
检测结果对比.png (32.77 KB, 下载次数: 36)
查看全部评分
使用道具 举报
签到天数: 4 天
[LV.2]偶尔看看I
签到天数: 2 天
[LV.1]初来乍到
本版积分规则 发表回复 回帖后跳转到最后一页
|小黑屋|联系我们|YFROBOT ( 苏ICP备20009901号-2 )
GMT+8, 2024-11-13 14:36 , Processed in 0.052525 second(s), 31 queries .
Powered by Discuz! X3.1
© 2001-2013 Comsenz Inc.