• Home
  • pcDuino
  • WiKi
  • Store
  • Distributors
  • Home
  • pcDuino
  • WiKi
  • Store
  • Distributors
HomepcDuinoArduino-ish ProgramGPIOpcDuino can help You Measure Air Particle Pollutio ...
Previous Next

pcDuino can help You Measure Air Particle Pollution PM2.5

Posted by: Sky Luo , December 16, 2013

[vc_row][vc_column width=”1/1″][vc_column_text]In this tutorial we are going to use Dust sensor on pcDuino to measure air pollution pm2.5.

图片1[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column width=”1/1″][vc_tour][vc_tab title=”Dust sensor” tab_id=”1387207523-1-41″][vc_column_text]图片2

Main feature:

  1. Output signal is PWM;
  2. Easy installation;
  3. Single-supply;

Parameter:

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

[/vc_column_text][/vc_tab][vc_tab title=”Compile and run” tab_id=”1387207523-2-96″][vc_column_text]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 D8

图片3

图片4

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

图片5

2. Click the run button:

图片6[/vc_column_text][/vc_tab][vc_tab title=”Sample Code” tab_id=”1387209864712-2-5″][vc_column_text]<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>[/vc_column_text][/vc_tab][/vc_tour][/vc_column][/vc_row]

Tags: GPIO, pcDuino

Share!
Tweet

Sky Luo

About the author

Comments are closed.

Category

  • Home
  • pcDuino
  • WiKi
  • Store
  • Distributors