空气颗粒度PM2.5的检测设计与实现

利用arduion开发板,空气颗粒度的检测装置来制作空气颗粒度的检测设备!

PM2.5是指大气中直径小于或等于2.5微米的颗粒物,也称为可入肺颗粒物。虽然PM2.5只是地球大气成分中含量很少的组分,但它对空气质量和能见度等有重要的影响。PM2.5粒径小,含有大量的有毒、有害物质,且在大气中的停留时间长、输送距离远,因而对人体健康和大气环境质量的影响更大。PM10表示颗粒度的直径小于10um的粒子,在空气中能被人群吸入到呼吸道,对人体的危害十分大。

检测空气颗粒度的其原理结构图如下图所示。

空气颗粒度PM2.5的检测设计与实现_第1张图片

注:PT:光电探测器;LED:发光二极管;Heater:加热器;Lens:透镜

  传感器采用粒子计数原理。模块内设置加热器,加热使得气流上升,外部空气进入模块内部,如有粉尘等粒子通过时,阻断LED光源,光电检测器检测不到光源,光电检测器则低电位输出;如无粒子通过,则光电检测器高电位输出,形成PMW脉冲宽度调制信号,信号经过放大输出。

         编程c语言代码如下:

/*
JST Pin 1 (Black Wire)  => Arduino GND
 JST Pin 3 (Red wire)    => Arduino 5VDC
 JST Pin 4 (Yellow wire) => Arduino Digital Pin 8
 */

int pin2_5 = 7;
int pin1 = 8;
int count=0;
float temp;
float add=0;
unsigned long duration2_5;
unsigned long duration1;

unsigned long starttime;
unsigned long sampletime_ms = 30000;//sampel 30s ;

unsigned long lowpulseoccupancy2_5 = 0;
unsigned long lowpulseoccupancy1 = 0;

float ratio2_5 = 0;
float ratio1 =0;

float concentration2_5 = 0;
float concentration1 = 0;
float concentration =0;

float PM2_5;
float PM[5];
float average;

void setup() {
  Serial.begin(9600);
  pinMode( 7 ,INPUT);
  pinMode( 8 ,INPUT);
  starttime = millis();//get the current time;
}

void loop()
{
 
  duration2_5 = pulseIn(pin2_5, LOW,100000);
  duration1 = pulseIn(pin1,LOW,100000);
       
  lowpulseoccupancy2_5 = lowpulseoccupancy2_5+duration2_5;
  lowpulseoccupancy1 = lowpulseoccupancy1+ duration1;
 
  if ((millis()-starttime) > sampletime_ms) //if the sampel time == 30s
  {  
    ratio2_5 = lowpulseoccupancy2_5/(sampletime_ms*10.0);  // Integer percentage 0=>100
    ratio1 = lowpulseoccupancy1/(sampletime_ms*10.0);  // Integer percentage 0=>100
    
    concentration2_5 = 1.1*pow(ratio2_5,3)-3.8*pow(ratio2_5,2)+520*ratio2_5+0.62; // using spec sheet curve
    concentration1 = 1.1*pow(ratio1,3)-3.8*pow(ratio1,2)+520*ratio1+0.62; // using spec sheet curve
      
    if(concentration1 > concentration2_5)
    {
      concentration = concentration1 - concentration2_5;//get the dust densty between 1um--2.5um;
      
      if(concentration >=0 && concentration <=333)
      PM2_5=0.186*concentration;
      
      else if(concentration >333 && concentration <=666)
      PM2_5 = 0.2*concentration;
      else
      
      PM2_5=0.185*concentration +1;
     //using spec sheet cuve;
      
      Serial.print("PM2_5: ");
      Serial.println(PM2_5);
      
      PM[count]=PM2_5;
      count++;
     
      if( 6 == count )
      {     
         count=0;     
         for(int i=0;i<6;i++)
         {
           Serial.print(PM[i]);
           Serial.print("--");
         }
         Serial.println();
         
        for(int i=1;i<6;i++)
          for(int j=0;j<6-i;j++)
          if(PM[j]>PM[j+1])
          {
            temp=PM[j+1];
            PM[j+1]=PM[j];
            PM[j]=temp;
          }   
          
        for(int i=0;i<6;i++)
         {
           Serial.print(PM[i]);
           Serial.print("--");
         }
         Serial.println();
        
        for(int i=1;i<5;i++)
         add+=PM[i];
         
        PM2_5 = add/4.0;
        Serial.print("PM2.5: ");
        Serial.print(PM2_5);
        Serial.println("ug/M3");
        Serial.println("");
      }
       add=0;
    }     
    lowpulseoccupancy2_5 = 0;
    lowpulseoccupancy1 = 0;
    starttime = millis();//get the current time again;
  }
 
}


得到的数据如下,基本符合空气的质量要求:

空气颗粒度PM2.5的检测设计与实现_第2张图片



你可能感兴趣的:(c,arduino,PM2.5,空气颗粒度)