• 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 :) 

  • 相关阅读:
    Unity StrangeIoc框架 (三)signal信号方式
    Unity StrangeIoc框架 (二)
    Unity StrangeIoc框架 (一)
    Android应用如何监听自己是否被卸载及卸载反馈功能的实现(第三版)
    2017年50道Java线程面试题
    常见Android面试题及答案(详细整理)
    Android 高级面试题及答案
    Android 面试精华题目总结
    android面试题总结加强再加强版(一)
    2017 Android 面试题 [ 基础与细节 ]
  • 原文地址:https://www.cnblogs.com/spaceship9/p/3386583.html
Copyright © 2020-2023  润新知