Keep yourself healthy by monitoring levels of air pollution in your home with this Arduino dust detector project!

Due to increasing air pollution and the associated health problems, measuring air quality is becoming more and more necessary in big cities. There are many sensors available on the market that allow you to do measure air quality and recently, I ordered Sharp's GP2Y1010AU0F optical dust sensor. This dust sensor is small in size and can detect dust and smoke particles in the environment. It consumes very little power while it’s running, making it ideal for an always-on monitoring system.

This tutorial focuses on how to connect the Sharp optical dust sensor to an Arduino. The reading of the sensor will then be displayed on an OLED screen. The system is packed into an old inhaler which allows you to blow air into the sensor for easy testing.

GP2Y1010AU0F Optical Dust Sensor

The sensor has a tiny six-pin connection interface, it comes with a connector when you usually buy it. The sensor generates an analog output signal on pin5- Vo, it does not require any external components for operation and requires only a 3.3V supply, making it easy to interface with the Arduino board. Some example applications of this sensor include:

  • Air purifier
  • Air conditioner
  • Air monitor
  • PM2.5 detector
GP2Y1010AU0F optical dust sensor

Sharp's GP2Y1010AU0F optical dust sensor.

Why I Chose the GP2Y1010AU0F

I chose this dust sensor for the following reasons:

  • It uses the latest technology for sensing, including an infrared LED, a set of lenses, a photodiode detector, and an electromagnetic shield.
  • It has a high sensitivity to dust conditions, followed by a fast response time between the sensor and the microcontroller.
  • Due to the three wires (VCC, GND, and signal) leading to the microcontroller, this sensor can be prepared using a simple hardware framework, making it easy for beginners to interface with the Arduino.
  • The sensor’s small size allows for easy installation in an air quality monitoring box or any other small DIY project case.

How Does the Dust Sensor Work?

The dust sensor uses an optical sensing method to detect dust. A photosensor and an infrared light-emitting diode which is known as an IR LED are optically arranged in the dust sensor module. The photo-sensor (PT) detects the reflected IR LED rays which are bounced off of the dust particles in the air.

The GP2Y1010AU0F module can sense the tiniest particles in the air, which lets it detect even cigarette smoke. A high output pulse from the sensor is triggered whenever it detects dust.

Required Materials

  • Arduino Nano/UNO
  • OLED128*32
  • Dust sensor GP2Y1010AU0F
  • Breadboard
  • 100ohm resistor
  • Capacitor of 220uf
  • Inhaler
  • Tubing
  • Round piece of plastic
  • Hot glue gun
ARDUINO_UNO_SHARP_RW_MP_image11.jpg

The required materials for the air quality monitoring system

Building the Inhaler Case

Grab an old inhaler and find a round piece of plastic (even a bottle cap will do the job). Glue one side of the pipe into the inhaler with a hot glue gun. The other side of the pipe goes to the dust area detector. Check out the images below. 

building a air quality sensor

Use an old inhaler and a plastic circle.

glue the piping to the inhaler

Glue one end of the piping to the inhaler.

attach piping to optical air sensor

Attach the other end of the piping to the sensor.

Arduino Dust Sensor Interface

Interface the dust sensor to the Arduino as shown in the fritzing diagram below. 

ARDUINO_UNO_SHARP_RW_MP_image10.jpg

Connect the 3.3V/5V pin of the Arduino board to the Vcc pin of the dust sensor module.

Connect the V-LED of the sensor to the 100Ω resistor. Connect the sensor’s LED-GND and S-GND pins to the ground pin of Arduino.

The LED pin of the sensor should be connected with Arduino’s digital pin12, which is known as the output pin of the dust sensor module.

The V0 pin — which is an Analog pin — must be connected with the Arduino analog pin to A0. The Arduino code will output the dust concentration level of the sensor in the OLED 128X32.

connections on sharp optical sensor

The connections on Sharp's optical dust sensor.

connections on sharp optical dust sensor


Note: For an Arduino Uno, connect pin Vo of the GP2Y1010AU0F to pin A0 of the Uno. Pin V-LED and pin Vcc of GP2Y1010AU0F can be connected to either 5V or 3.3V of the Uno. The same applies to the Vcc of the OLED display. Use pins A4 and A5 as the SDA and SCL interface.

ARDUINO_UNO_SHARP_RW_MP_image12.jpg

The final air quality tester.

        /* 
Upload Source Code
*/
#include <Arduino.h>
#include <U8g2lib.h>
#include <SPI.h>
#include <Wire.h>

U8G2_SSD1306_128X32_UNIVISION_F_HW_I2C u8g2(U8G2_R0); 
int measurePin = A0;
int ledPower = 12;

unsigned int samplingTime = 280;
unsigned int deltaTime = 40;
unsigned int sleepTime = 9680;

float voMeasured = 0;
float calcVoltage = 0;
float dustDensity = 0;

void setup(){
  Serial.begin(9600);
  u8g2.begin();
  pinMode(ledPower,OUTPUT);
  u8g2.clearBuffer();          // clear the internal memory
   u8g2.setFont(u8g2_font_logisoso24_tr);  // choose a suitable font at https://github.com/olikraus/u8g2/wiki/fntlistall
   u8g2.drawStr(8,29,"Welcome");  // write something to the internal memory
   u8g2.sendBuffer();         // transfer internal memory to the display
   delay(800);

   u8g2.clearBuffer();         // clear the internal memory
   u8g2.setFont(u8g2_font_logisoso24_tr);  // choose a suitable font at https://github.com/olikraus/u8g2/wiki/fntlistall
   u8g2.drawStr(40,26,"TO");  // write something to the internal memory
   u8g2.sendBuffer();         // transfer internal memory to the display
   delay(800);
   u8g2.clearBuffer();         // clear the internal memory
   u8g2.setFont(u8g2_font_logisoso20_tr);  // choose a suitable font at https://github.com/olikraus/u8g2/wiki/fntlistall
   u8g2.drawStr(16,26,"Maker.Pro");  // write something to the internal memory
   u8g2.sendBuffer();         // transfer internal memory to the display
   delay(2000);
}

void loop(){
  
  
  digitalWrite(ledPower,LOW);
  delayMicroseconds(samplingTime);

  voMeasured = analogRead(measurePin);

  delayMicroseconds(deltaTime);
  digitalWrite(ledPower,HIGH);
  delayMicroseconds(sleepTime);

  calcVoltage = voMeasured*(5.0/1024);
  dustDensity = 0.17*calcVoltage-0.1;

  if ( dustDensity < 0)
  {
    dustDensity = 0.00;
  }

  Serial.println("Raw Signal Value (0-1023):");
  Serial.println(voMeasured);

  Serial.println("Voltage:");
  Serial.println(calcVoltage);

  Serial.println("Dust Density:");
  Serial.println(dustDensity);
   u8g2.clearBuffer();         // clear the internal memory
   u8g2.setFont(u8g2_font_pxplusibmvga9_tr);  // choose a suitable font at https://github.com/olikraus/u8g2/wiki/fntlistall
   u8g2.drawStr(0,15,"Dust Density ");  // write something to the internal memory
   u8g2.setCursor(0, 31);
   u8g2.print(dustDensity); 
  // u8g2.drawStr(0,31,"AHHH123");  // write something to the internal memory
   
//   u8g.print("Hello World!")
   u8g2.sendBuffer();         // transfer internal memory to the display

  delay(1000);
}
    

After uploading the code, you should be able to see something similar to this video. In the video, I am using some talcum powder and blowing into the pipe to test the sensor.

Reginald Watson
I love challenging myself by creating new projects using different microcontrollers to see what I can come up with.