Arduino PM2.5 detector

Arduino PM2.5 detector

Introduction
GP2Y1010AU0F is a dust sensor supported by optical sensing system. An infrared emitting diode(IRED) and an phototransistor are diagonally arranged into this device. It detects the reflected light of dust in air. Especially, it is effective to detect very fine particle like the cigarette smoke. In addition it can distinguish smoke from house dust by pulse pattem of output voltage.

Components
– 1 * Adeept UNO R3 Board
– 1 * Sharp GP2Y10 Sensor
– 1 * 150Ω Resistor
– 1 * 220uF Capacitor
– 1 * Breadboard
– 1 * USB Cable
– 1 * 6-Pin Wires
– 3 * Jumper Wires

Experimental Principle 
The optical dust sensor (GP2Y1010AU0F) is particularly effective in detecting very fine particles, such as cigarette smoke, and is  commonly used in air purifier system.
In the apparatus, an infrared light emitting diode and a phototransistor are arranged diagonally so as to allow them to detect dust reflected light in the air.The sensor has a very low current consumption (maximum 20mA, 11 mA typical), it can carry up to 7VDC sensor. The output analog voltage is proportional to the measured dust concentration, the sensitivity of 0.5V / 0.1mg / m3.
voltage:5-7V
Operating temperature: -10-65 degrees Celsius
Current consumption: 20mA max
Minimum particle detection: 0.8 micron
Sensitivity: 0.5V / (0.1mg / m3)
Clean Air Voltage: 0.9V typ
Working temperature: -10 ~ 65 ℃
Storage temperature: -20 ~ 80 ℃
Service life: 5 years
Size: 46mm × 30mm × 17.6mm
Weight: 15g

Internal schematic

Outline Dimensions

Experimental Procedures
Step 1: Build the circuit

Step 2: Program  AdeeptPM25.ino

/***********************************************************
File name: AdeeptPM25.ino
Description:  Use the GP2 sensor to detect the environment
             you will see the data in the serial monitor 
Website: www.adeept.com
E-mail: support@adeept.com
Author: Tom
Date: 2016/12/27 
***********************************************************/
 #define PIN_DATA_OUT A0 //Connect the IO port of the GP2 sensor analog A0 output
 #define PIN_LED_VCC 2 //The pin in the GP2 sensor that supplies power to the internal Led
 const int DELAY_BEFORE_SAMPLING = 280; //Waiting time before sampling
 const int DELAY_AFTER_SAMPLING = 40; //Wait time after sampling
 const int DELAY_LED_OFF = 9680; //Intervals

/**
 * Read the GP2 sensor output voltage
*/
double getOutputV() {
  digitalWrite(PIN_LED_VCC, LOW);
  delayMicroseconds(DELAY_BEFORE_SAMPLING);
  double analogOutput = analogRead(PIN_DATA_OUT);
  delayMicroseconds(DELAY_AFTER_SAMPLING);
  digitalWrite(PIN_LED_VCC, HIGH);
  delayMicroseconds(DELAY_LED_OFF);
  //Arduino analog read value range is 0 ~ 1023, the following conversion is 0 ~ 5v
  double outputV = analogOutput / 1024 * 5;
  return outputV;
}

/**
   Calculate the dust density based on the output voltage
*/
double getDustDensity(double outputV) {
  //Output voltage and dust density conversion formula: ug / m3 = (V - 0.9) / 5 * 1000
  double ugm3 = (outputV - 0.9) / 5 * 1000;
  //Remove the undetected range
  if (ugm3 < 0) {
    ugm3 = 0;
  }
  return ugm3;
}

/**
   Calculate AQI based on dust density
   Environmental air quality index (AQI) technical requirements (Trial)
 */
double getAQI(double ugm3) {
  double aqiL = 0;
  double aqiH = 0;
  double bpL = 0;
  double bpH = 0;
  double aqi = 0;
  //According to the correspondence between pm2.5 and aqi were calculated aqi
  if (ugm3 >= 0 && ugm3 <= 35) {
    aqiL = 0;
    aqiH = 50;
    bpL = 0;
    bpH = 35;
  } else if (ugm3 > 35 && ugm3 <= 75) {
    aqiL = 50;
    aqiH = 100;
    bpL = 35;
    bpH = 75;
  } else if (ugm3 > 75 && ugm3 <= 115) {
    aqiL = 100;
    aqiH = 150;
    bpL = 75;
    bpH = 115;
  } else if (ugm3 > 115 && ugm3 <= 150) {
    aqiL = 150;
    aqiH = 200;
    bpL = 115;
    bpH = 150;
  } else if (ugm3 > 150 && ugm3 <= 250) {
    aqiL = 200;
    aqiH = 300;
    bpL = 150;
    bpH = 250;
  } else if (ugm3 > 250 && ugm3 <= 350) {
    aqiL = 300;
    aqiH = 400;
    bpL = 250;
    bpH = 350;
  } else if (ugm3 > 350) {
    aqiL = 400;
    aqiH = 500;
    bpL = 350;
    bpH = 500;
  }
  //formula: aqi = (aqiH - aqiL) / (bpH - bpL) * (desity - bpL) + aqiL;
  aqi = (aqiH - aqiL) / (bpH - bpL) * (ugm3 - bpL) + aqiL;
  return aqi;
}

/**
   According to aqi access level description
*/
String getGradeInfo(double aqi) {
  String gradeInfo;
  if (aqi >= 0 && aqi <= 50) {
    gradeInfo = String("Perfect");
  } else if (aqi > 50 && aqi <= 100) {
    gradeInfo = String("Good");
  } else if (aqi > 100 && aqi <= 150) {
    gradeInfo = String("Mild polluted");
  } else if (aqi > 150 && aqi <= 200) {
    gradeInfo = String("Medium polluted");
  } else if (aqi > 200 && aqi <= 300) {
    gradeInfo = String("Heavily polluted");
  } else if (aqi > 300 && aqi <= 500) {
    gradeInfo = String("Severely polluted");
  } else {
    gradeInfo = String("Broken roof!!!");
  }
  return gradeInfo;
}

void setup() {
  Serial.begin(115200);
  pinMode(PIN_DATA_OUT, INPUT); //Defined as input (ADC reads analog)
  pinMode(PIN_LED_VCC, OUTPUT); //Defined as output
}

void loop() {
  double outputV = getOutputV(); //Sampling Get the output voltage
  double ugm3 = getDustDensity(outputV); //Calculate the dust concentration
  double aqi = getAQI(ugm3); //Calculate aqi
  String gradeInfo = getGradeInfo(aqi); //Calculate the level

  //Print to the serial port
  Serial.println(String("outputV=") + outputV + "\tug/m3=" + ugm3 + "\tAQI=" + aqi + "\tgradeInfo=" + gradeInfo);

  //The next detection is performed every 1 second
  delay(1000);
}

Step 3: Compile and download the sketch to the UNO R3 board.

Leave a Reply