Datasheet

7
6. Usage
Here is a demo to show you how to obtain PM concentration data from this Grove - Dust Sensor.
1. Plug the dust sensor into digital port D8 on the Grove - Base Shield. It can only be D8, because
the operation of this sensor involves sampling, a function only can be achieved by D8, the capture
input pin of Atmage328P, on Arduino/Seeeduino.
Also you can connect Grove - Dust sensor to Arduino UNO without Base Shield :
Arduino UNO
Dust Sensor
5V
Red wire
GND
Black wire
Digit 8
Yellow wire
2. Copy and paste the demo code below to a new Arduino sketch.
/* 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;
}