Introduction: PcDuino Can Help You Measure Air Particle Pollution PM2.5

Picture of PcDuino Can Help You Measure Air Particle Pollution PM2.5

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

Step 1: Dust Sensor

Picture of Dust Sensor

Main feature:

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

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

Step 2: Compile and Run

Picture of Compile and Run

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

Step 3: Run Code

Picture of Run Code

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

Step 4: 2. Click the Run Button

Picture of 2. Click the Run Button

2. Click the run button:

Step 5: 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>

Comments

About This Instructable

1,697views

20favorites

License:

More by pcduino:Use Button to Control LED on pcDuino with JavaUse Arduino and RS232 Shield to interface Integrated UHF RFID reader LSID-0702Experiment 4 Serial Port Communication
Add instructable to: