熱門文章

2017年8月30日 星期三

PM2.5(組裝)

檢測灰塵PM2.5



Q39 GP2Y1010AU0F 灰塵傳感器 檢測灰塵PM2.5 粉塵傳感器
原始 Code
http://lafudo.blogspot.tw/2013/12/arduino-gp2y1010au0fpm25.html
https://pwfee.com/2015/12/GP2Y1010AU0F
http://www.instructables.com/id/How-to-Interface-With-Optical-Dust-Sensor/

檢討:
PM2.5檢測單位 粒徑2.5u , mg/m3,不是無塵室要求的規格,但可供參考


--程式碼如下--
/*
 * 由 Dust-LCD-Show-3 修改來
 * 
 *  修改 59 行 dustDensity = 0.17 * calcVoltage - 0.1; //得出浓度( mg/m³ )
 *     成 dustDensity = 0.17 * calcVoltage - 0.072; //得出浓度( mg/m³ )不成負數
 *   
*/
#include 
LiquidCrystal_I2C lcd(0x3F,16,2);

int measurePin = 0; //Connect dust sensor to Arduino A0 pin
int ledPower = 2;   //Connect 3 led driver pins of dust sensor to Arduino D2
  
int samplingTime = 280;
int deltaTime = 40;
int sleepTime = 9680;
  
float voMeasured = 0;
float calcVoltage = 0;
float dustDensity = 0;
float AQI = 0  ;
//int dustPin=0;
//float dustVal=0;

void setup(){
  lcd.init();
  // Print a message to the LCD.
  lcd.backlight();
  lcd.setCursor(4,0);
  lcd.print("ToppyBio");
  lcd.setCursor(2,1);
  lcd.print("Hello, world!");
  delay(2000);
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("PM2.5:");
  lcd.setCursor(11,0);
  lcd.print("ug/m3");
  lcd.setCursor(0,1);
  lcd.print("AQI:");
  lcd.setCursor(16,1);
  lcd.print("P Value");
  Serial.begin(9600);
  pinMode(ledPower,OUTPUT);
}
 
void loop(){
  
  digitalWrite(ledPower,LOW); // power on the LED
  delayMicroseconds(samplingTime);
  
  voMeasured = analogRead(measurePin); // read the dust value
  
  delayMicroseconds(deltaTime);
  digitalWrite(ledPower,HIGH); // turn the LED off
  delayMicroseconds(sleepTime);
  
  // 0 - 5V mapped to 0 - 1023 integer values
  // recover voltage
  calcVoltage = voMeasured * (5.0 / 1024.0);
  
  // linear eqaution taken from http://www.howmuchsnow.com/arduino/airquality/
  // Chris Nafis (c) 2012
  dustDensity = 0.17 * calcVoltage - 0.1 ; //得出浓度( mg/m³ ) 
  AQI = (float(voMeasured/1024)-0.0356)*120000*0.035 ;
  Serial.print("Raw Signal Value (0-1023): ");
  Serial.print(voMeasured);
  
  Serial.print("   Voltage: ");
  Serial.print(calcVoltage);
  
  Serial.print("   Dust Density: ");
  Serial.print(dustDensity * 1000); // 这里使用更为广泛的单位( μg/m3 )
  Serial.println(" ug/m3 ");
  Serial.print("   Dust Value(particle number): ");
  Serial.println((float(voMeasured/1024)-0.0356)*120000*0.035);
  
 /*  lcd.setCursor(6,0);
     lcd.print(dustDensity * 1000);  
     lcd.setCursor(10,1);
     lcd.print(AQI);
 */
 if(AQI <= 75){
     lcd.print("     ");
     lcd.setCursor(4,1);
     lcd.print("Exln");
     lcd.setCursor(6,0);
     lcd.print(dustDensity * 1000);  
     lcd.setCursor(10,1);
     lcd.print(AQI);
  }
  else if(AQI > 75 && AQI <150 1000="" dustdensity="" else="" if="" lcd.print="" lcd.setcursor="" od="">= 150 && AQI <300 1000="" dustdensity="" else="" if="" lcd.print="" lcd.setcursor="" ood="">= 300 && AQI <1050 1000="" dustdensity="" else="" enrl="" if="" lcd.print="" lcd.setcursor="">= 1050 && AQI <3000 1000="" ad="" dustdensity="" else="" if="" lcd.print="" lcd.setcursor="">= 3000 ){
     lcd.setCursor(4,1);
     lcd.print("     ");
     lcd.setCursor(4,1);
     lcd.print("V Bad ");
   lcd.setCursor(6,0);
     lcd.print(dustDensity * 1000);  
     lcd.setCursor(10,1);
     lcd.print(AQI);
   }       
           
   delay(1000); 
}

1 則留言:

  1. 此儀器正好可以用在無塵室檢測
    是否可以承接外銷歐洲的訂單

    回覆刪除