熱門文章

2017年8月30日 星期三

落塵數(組裝)

PMS5003T (攀藤G5T) 是一款數字式通用顆粒物濃度傳感器,PMS5003T 可以用於獲得單位體積內空氣中懸浮顆粒物的質量和數量,並以數字接口形式輸出。



原始 Code
http://jaihung.blogspot.tw/2017/02/pm2.html

原始 data sheet
https://www.amazon.com/clouddrive/share/XInzym7rUycKLEYsn3h9oZ1ojZyj2bs8ySLoo1vAlk?_encoding=UTF8&mgh=1&ref_=cd_ph_share_link_copy

此Lcd 原為OLED 0.96" 修改成 Nokia5110 LCD,原始code沒有0.5um、1um等的顆粒數目,查找原始 data sheet,其實可以show 出來,花了點時間,讓他show 出來,即可,啊!啊!又第一名了,這樣LCD show 的才是無塵室 10萬級的顆粒數。



LCD影像說明:
T:溫度
H:濕度
pm1 , pm2.5 , pm10:單位ug/m^3
2.5u, 1.0u, 0.5u, 0.3u:單位,數目/粒徑


--程式碼如下--
/*
 * 由 pm3003-4改名 170830
 * Sensor採用 psm5003T,非psm3003,採用psm3003程式碼修改
 * G3-Arduino原始程式碼〈僅供參考〉
 * line 40  count > 15 modify to count > 40 ,all data appear
 * ---------------------------------------------------------
 * 170811-增加nokia5110 lcd ---------
 * TTL 電平轉換模塊 四路排針  5V-3.3V
 * -----------------------------------------------------------
 * 170811-修改 LCD 數字顯示問題--line 74,78,84
 */
/* 
 * Arduino pins connected to Nokia pins:
   CLK=8,    red
   DIN(DN)=9, blue
   CE=6, yellow
   DC=5, green
   RST=7 orange
   VCC            = %V  black
   GND                  white
    BL            =3.3v grey
*/

/*  pm5003T 線 腳位 (TX綠 接 Arduino pin D2(rx) )
 *                   (SET白 接 Arduino pin D4也可不接)
 vcc GND  SET  RX  TX  RESET
 紫  橘   白   藍  綠  黃
*/
#include <softwareserial.h>
#include <U8glib.h>  // U8glib for Nokia LCD
#define backlight_pin 11

U8GLIB_PCD8544 u8g(8, 9, 6, 5, 7); 
SoftwareSerial mySerial(2, 3);//rx,tx
long pmcf10=0;
long pmcf25=0;
long pmcf100=0;
long pmat10=0;
long pmat25=0;
long pmat100=0;
long pm03PNO =0;
long pm05PNO =0;
long pm10PNO =0;
long pm25PNO =0;
long Temperature =0;
long Humidity =0;

char buf[50];
void draw() {
    u8g.setFont(u8g_font_5x8);
    u8g.drawStr(0, 10, "T=");//Temperature 左1
    u8g.setPrintPos(15, 10);
    u8g.print(int(Temperature/10));
    u8g.drawStr(26, 10, "(^C)");
    u8g.drawStr(48 ,10, "H=");//Humidity 右1
    u8g.setPrintPos(60, 10);
    u8g.print(int(Humidity/10));
    u8g.drawStr(70, 10, "(%)");
    u8g.drawStr(0, 20, "PM1=");//pm1.0 左2
    u8g.setPrintPos(20, 20);
    u8g.print(int(pmat10));
    u8g.drawStr(40, 20, "PM2.5=");//PM2.5 右2
     //u8g.setFont(u8g_font_6x10);
     //u8g.setFont(u8g_font_fub20);    
    u8g.setPrintPos(70, 20);
    u8g.print(int(pmat25));            
    u8g.setFont(u8g_font_5x8);
    u8g.drawStr(0, 28, "PM10=");//PM10,0 左3
    u8g.setPrintPos(24, 28);
    u8g.print(int(pmat100));      
    u8g.drawStr(40, 28, "2.5u=");//2.5u 右3
    u8g.setPrintPos(70, 28);
    u8g.print(int(pm25PNO));    
    u8g.drawStr(0, 38, "1.0u=");//1.0u 左4
    u8g.drawStr(24, 38, "     ") ;//修改 LCD 數字顯示問題
    u8g.setPrintPos(24, 38);
    u8g.print(int(pm10PNO));
    u8g.drawStr(44, 38, "05u=");//0.5u 右4
    u8g.drawStr(64, 38, "     ") ;//修改 LCD 數字顯示問題
    u8g.setPrintPos(64, 38);//
    u8g.print(int(pm05PNO));
    u8g.drawStr(0, 48, "0.3u=");//0.3u 左5
    u8g.drawStr(28, 48, "      ") ;//修改 LCD 數字顯示問題
    u8g.setPrintPos(28, 48);
    u8g.print(int(pm03PNO));    
    //u8g.drawStr(60, 47, "(ug/m3)"); 
}
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
mySerial.begin(9600);
}
/*u8g.firstPage();  
    do {
      draw();
      u8g.setFont(u8g_font_5x8);
      u8g.drawStr(0, 52, "(Normal)");
      } while( u8g.nextPage() );
*/      
void loop() {
// put your main code here, to run repeatedly:
int count = 0;
unsigned char c;
unsigned char high;
while (mySerial.available()) {
c = mySerial.read();
if((count==0 && c!=0x42) || (count==1 && c!=0x4d)){
Serial.println("check failed");
break;
}
if(count > 40){
Serial.println("complete");
break;
}
else if(count == 4 || count == 6 || count == 8 || count == 10 || count == 12 || count == 14|| count == 16|| count == 18|| count == 20|| count == 22|| count == 24|| count == 26|| count == 28 ) high = c;
else if(count == 5){
pmcf10 = 256*high + c;
Serial.print("CF=1, PM1.0=");
Serial.print(pmcf10);
Serial.println(" ug/m3");
}
else if(count == 7){
pmcf25 = 256*high + c;
Serial.print("CF=1, PM2.5=");
Serial.print(pmcf25);
Serial.println(" ug/m3");
}
else if(count == 9){
pmcf100 = 256*high + c;
Serial.print("CF=1, PM10=");
Serial.print(pmcf100);
Serial.println(" ug/m3");
}
else if(count == 11){
pmat10 = 256*high + c;
Serial.print("atmosphere, PM1.0=");
Serial.print(pmat10);
Serial.println(" ug/m3");
}
else if(count == 13){
pmat25 = 256*high + c;
Serial.print("atmosphere, PM2.5=");
Serial.print(pmat25);
Serial.println(" ug/m3");
}
else if(count == 15){
pmat100 = 256*high + c;
Serial.print("atmosphere, PM10=");
Serial.print(pmat100);
Serial.println(" ug/m3");
}
else if(count == 17){
pm03PNO= 256*high + c;
Serial.print("above0.3um, no=");
Serial.print(pm03PNO);
Serial.println(" number");
}
else if(count == 19){
pm05PNO = 256*high + c;
Serial.print("above0.5um, no=");
Serial.print(pm05PNO);
Serial.println(" number");
}
else if(count == 21){
pm10PNO = 256*high + c;
Serial.print("above 1.0um, no=");
Serial.print(pm10PNO);
Serial.println(" number");
}
else if(count == 23){
pm25PNO = 256*high + c;
Serial.print("above 2.5um, no=");
Serial.print(pm25PNO);
Serial.println(" number");
}
else if(count == 25){
Temperature = 256*high + c;
Serial.print("Temperature = ");
Serial.print(Temperature/10);
Serial.println(" ^C ");
}
else if(count == 27){
Humidity = 256*high + c;
Serial.print("Humidity = ");
Serial.print(Humidity/10) ;
Serial.println(" % ");
}
count++;
}
while(mySerial.available()) mySerial.read();
Serial.println();
u8g.firstPage();  
    do {
      draw();
    } while( u8g.nextPage() );
delay(4000);
}

2 則留言:

  1. 這檢測儀器剛好可以應用在無塵室的檢驗
    我歐洲客戶有需求
    請問是否可以承接歐洲外銷訂單

    回覆刪除