zoukankan      html  css  js  c++  java
  • Arduino 各种模块篇 粉尘传感器 dust sensor 空气质量检测

    Testing a sensor from here.

    http://www.seeedstudio.com/wiki/Grove_-_Dust_Sensor

    It's a dust sensor. Everyone can buy it anywhere also. It's a cheep one actually.

    We can find its document here: http://www.seeedstudio.com/wiki/images/4/4c/Grove_-_Dust_sensor.pdf

    Dust sensor.JPG

    It looks good.

    It's more cheaper if you buy it from taobao.com or other whole sellers.

    Now cut the crap, just send me those codes here:

    /* Grove - Dust Sensor Demo v1.0
     Interface to Shinyei Model PPD42NS Particle Sensor
     Program by Christopher Nafis 
     Written April 2012
     
     http://www.seeedstudio.com/depot/grove-dust-sensor-p-1050.html
     http://www.sca-shinyei.com/pdf/PPD42NS.pdf
     
     JST Pin 1 (Black Wire)  => Arduino GND
     JST Pin 3 (Red wire)    => Arduino 5VDC
     JST Pin 4 (Yellow wire) => Arduino Digital Pin 8
     */
    
    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(",");
        Serial.print(ratio);
        Serial.print(",");
        Serial.println(concentration);
        lowpulseoccupancy = 0;
        starttime = millis();
      }
    }

    Here's what you can get 

    via serial promte, you can see:

    Dust Sensor Output Score.jpg

    For more information , you can check this out the link above.

    Now please let me explain it from the bottom of it:

    Let's see what the spec sheet carve of it:

    The curve indicates that the bigger of the Concentration value is, the higher of the Low Pluse Occupancy will be.

    So what's the Low Pulse Occupancy Time perentage for?

    Let's check out this:

    we count the time from the starting moment of the low pulse begins until the moment of next high pulse stops.

    The time we can get is the cycle period. We can caculate the ratio of the LowPluseOccupancyTime/TheTimeWeSetToMeasure

        # radio = LowPluseOccupancyTime/TheTimeWeSetToMeasure

    With help of the chart which indicates the relationship of between the LowPulseOccupancyTimePercentage and the concentration, we can get the air quality value.

    Characteristics.jpg

    the unit of the concentration is   : PCS/Liter.

    PCS/liter is short for Particals / Liter 

    ####################3

    P.S. : There is another good air quality measuring module which looks like this :https://www.sparkfun.com/products/9689

    I haven't tested it. But it looks neat and somehow better I guess.

    So my next project will have something to do with a LIVE BROADCASTING AIR QUALITY STATION!

    Let's see :) 

  • 相关阅读:
    input不可编辑
    span width无效
    react配置rem解决移动端适配问题
    iframe 根据内容自适应高度-终极解决方案
    页面导入样式时,使用link和@import有什么区别?
    怎么让Chrome支持小于12px 的文字?
    React Hook 父子组件相互调用方法
    CSS3实现毛玻璃效果
    React阻止组件渲染
    JSX 中内联条件渲染的方法
  • 原文地址:https://www.cnblogs.com/spaceship9/p/3386583.html
Copyright © 2011-2022 走看看