久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费
標題:
arduino空氣質(zhì)量檢測
[打印本頁]
作者:
怎末回事
時間:
2020-2-16 15:49
標題:
arduino空氣質(zhì)量檢測
本系統(tǒng)主要是通過arduino控制激光粉塵傳感器來檢測空氣中的PM2.5及其他氣體含量,并在lcd1602上顯示出來。具體詳細代碼在壓縮包。
#include <Arduino.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd( 7, 6, 5, 4, 3, 2);
#define LENG 31 //0x42 + 31 bytes equal to 32 bytes
unsigned char buf[LENG];
int PM01Value=0; //define PM1.0 value of the air detector module
int PM2_5Value=0; //define PM2.5 value of the air detector module
int PM10Value=0; //define PM10 value of the air detector module
void setup()
{
Serial.begin(9600); //使用串口0
Serial.setTimeout(1500); //設置超時時間為1500毫秒(大于傳感器傳送數(shù)據(jù)周期1秒)
// lcd.print("PM1.0: ");
// lcd.print(PM01Value);
//lcd.println(" ug/m3");
// lcd.print("PM1 0: ");
//lcd.print(PM10Value);
//lcd.println(" ug/m3");
//lcd.println();
}
void loop()
{
if(Serial.find(0x42)){ //檢測到0x42時,開始讀取
Serial.readBytes(buf,LENG);
if(buf[0] == 0x4d)
{
if(checkValue(buf,LENG))
{
PM01Value=transmitPM01(buf); //count PM1.0 value of the air detector module
PM2_5Value=transmitPM2_5(buf);//count PM2.5 value of the air detector module
PM10Value=transmitPM10(buf); //count PM10 value of the air detector module
}
}
}
static unsigned long OledTimer=millis();
if (millis() - OledTimer >=1000)
{
OledTimer=millis();
Serial.print("PM1.0: ");
Serial.print(PM01Value);
Serial.println(" ug/m3");
Serial.print("PM2.5: ");
Serial.print(PM2_5Value);
Serial.println(" ug/m3");
Serial.print("PM1 0: ");
Serial.print(PM10Value);
Serial.println(" ug/m3");
Serial.println();
}
lcd.begin(16, 2);
lcd.setCursor(0,0);
lcd.print("PM2.5: ");
lcd.print(PM2_5Value);
lcd.println("ug/m3 ");
lcd.setCursor(0,1);
lcd.print("PM10: ");
lcd.print(PM10Value);
lcd.println("ug/m3 ");
lcd.println();
}
char checkValue(unsigned char *thebuf, char leng)
{
char receiveflag=0;
int receiveSum=0;
for(int i=0; i<(leng-2); i++){
receiveSum=receiveSum+thebuf[i];
}
receiveSum=receiveSum + 0x42;
if(receiveSum == ((thebuf[leng-2]<<8)+thebuf[leng-1])) //check the serial data
{
receiveSum = 0;
receiveflag = 1;
}
return receiveflag;
}
int transmitPM01(unsigned char *thebuf)
{
int PM01Val;
PM01Val=((thebuf[3]<<8) + thebuf[4]); //count PM1.0 value of the air detector module
return PM01Val;
}
//transmit PM Value to PC
int transmitPM2_5(unsigned char *thebuf)
{
int PM2_5Val;
PM2_5Val=((thebuf[5]<<8) + thebuf[6]);//count PM2.5 value of the air detector module
return PM2_5Val;
}
//transmit PM Value to PC
int transmitPM10(unsigned char *thebuf)
{
int PM10Val;
PM10Val=((thebuf[7]<<8) + thebuf[8]); //count PM10 value of the air detector module
return PM10Val;
}
復制代碼
空氣質(zhì)量檢測PM2.5.zip
2020-2-16 15:49 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
61.12 KB, 下載次數(shù): 13, 下載積分: 黑幣 -5
歡迎光臨 (http://www.zg4o1577.cn/bbs/)
Powered by Discuz! X3.1
主站蜘蛛池模板:
欧美色综合一区二区三区
|
亚洲人人
|
欧美精品乱码久久久久久按摩
|
看一级毛片视频
|
国产黄色在线观看
|
91久久综合亚洲鲁鲁五月天
|
91在线综合
|
www.亚洲一区二区三区
|
在线观看国产
|
97视频在线观看网站
|
亚洲欧美v
|
日本成人在线网址
|
人人干视频在线
|
精品成人一区二区
|
亚洲精品二三区
|
神马影院一区二区三区
|
欧美精品一区二区蜜桃
|
成人在线视频网
|
国产一区二区在线免费
|
中文字幕亚洲一区二区三区
|
亚洲精品电影网在线观看
|
日本二区
|
国产精品福利久久久
|
国产精品日韩一区二区
|
日韩一区二区免费视频
|
国产欧美日韩精品一区
|
一级毛片免费看
|
密色视频
|
欧美lesbianxxxxhd视频社区
|
在线视频一区二区
|
国产欧美精品
|
免费中文字幕日韩欧美
|
中文字幕av色
|
欧美v在线观看
|
国产伦一区二区三区四区
|
夜夜夜操
|
亚洲九九精品
|
亚洲国产精品一区二区第一页
|
国产精品美女久久久
|
91视频观看
|
亚洲伦理自拍
|