PcDuino Can Help You Measure Air Particle Pollution PM2.5

by pcduino in Circuits > Arduino

2105 Views, 20 Favorites, 0 Comments

PcDuino Can Help You Measure Air Particle Pollution PM2.5

图片1.png
In this tutorial we are going to use Dust sensor on pcDuino to measure air pollution pm2.5.

Dust Sensor

图片2-300x224.png
Main feature:

Output signal is PWM;
Easy installation;
Single-supply;
Parameter:

5VDC;
Scope of detecting particles:Max 8000pcs/283ml;

Compile and Run

图片one.png
图片two.png
Hardware:

1 x pcDuino
1 x Dust Sensor
Several jumper wire
Wiring diagram:

Dust Sensor Pin 1  => pcDuino GND
Dust Sensor Pin 3  => pcDuino 5V
Dust Sensor Pin 4  => pcDuino D8v

Run Code

图片three.png
Run code: (You need to preheat the dust sensor more than 3 minutes before first use )

1. Launch Arduino IDE  that comes with  pcDuino and enter the following code (the code is shown in next tab):

2. Click the Run Button

图片four.png
2. Click the run button:

Sample Code

<code>

/************************************/
/* Dust Sensor Pin 1 => pcDuino GND */
/* Dust Sensor Pin 3 => pcDuino 5V */
/* Dust Sensor Pin 4 => pcDuino D8 */
/************************************/

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()
{
pinMode(pin,INPUT);
starttime = millis();//get the current time;
}

void loop()
{
duration = pulseIn(pin,LOW,1000000);
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
printf(“lowpulseoccupancy: %ld \nratio: %f \nconcentration: %f\n\n”,lowpulseoccupancy,ratio,concentration);
lowpulseoccupancy = 0;
starttime = millis();
}
}

</code>