Datasheet

8
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("concentration = ");
Serial.print(concentration);
Serial.println(" pcs/0.01cf");
Serial.println("\n");
lowpulseoccupancy = 0;
starttime = millis();
}
}
In this program, the seeeduino samples the total duration of "logic low" in 30s, and this duration
illustrates the dust density of environment. Open serial monitor, we can read air quality's value
detected by sensor from pc serial port.
The result above consists of three parts: lowpulseoccupancy, ratio and concentration.
"lowpulseoccupancy" represents the Lo Pulse Occupancy Time(LPO Time) detected in given 30s.
Its unit is microsecond.
"ratio" reflects on which level LPO Time takes up the whole sample time.