Sharp Dust Sensor GP2Y1010AU

In this exercise with the use of our Arduino Yún, we learn to build our detector air quality. To do this we will use the capabilities of the GP2Y1010AU0F. It's a dust sensor by optical sensing system with an infrared emitting diode (IRED) and a phototransistor that 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. The output of the sensor is an analog voltage proportional to the measured dust density, with a sensitivity of 0.5V/0.1mg/m3.

What do we need

  • an Arduino Yún board
  • a Sharp Optical Dust Sensor (GP2Y1010AU0F)
  • a breadboard
  • a 220 uF capacitor
  • a 150 Ohm resistor
  • a bunch of wires

The circuit


Be sure to follow the connections shown in the fritzing circuit  and in the next table :

Sharp pin 1 (V-LED)          => 5V (connected to 150ohm resistor,220 uF capacitor)
Sharp pin 2 (LED-GND)     => Arduino GND pin
Sharp pin 3 (LED)             => Arduino pin 2
Sharp pin 4 (S-GND)         => Arduino GND pin
Sharp pin 5 (Vo)               => Arduino A0 pin
Sharp pin 6 (Vcc)              => 5V

The code

/* Detector air quality with Arduino Yun and          **
** Optical Dust Sensor (GP2Y1010AU0F)              */

int dustPin = 0; // dust sensor - Arduino A0 pin
int ledP = 2;    

float voMeasured = 0;
float calcVoltage = 0;
float dustDensity = 0;
void setup(){
void loop(){
  digitalWrite(ledP,LOW); // power on the LED
  voMeasured = analogRead(dustPin); // read the dust value
  digitalWrite(ledP,HIGH); // turn the LED off
  // 0 - 5V mapped to 0 - 1023 integer values
  // recover voltage
  calcVoltage = voMeasured * (5.0 / 1024.0);
  dustDensity = 0.17 * calcVoltage - 0.1;
  Serial1.print("Raw Signal Value(0-1023) : ");
  Serial1.print(" - Voltage: ");
  Serial1.print(" - Dust Density: ");
  Serial1.println(dustDensity); // mg/m3
Write or paste code in Arduino IDE, then load the sketch on Yún board.

Python Serial Test

Read data from shell. 
To do this we used the included library “pyserial”. You must create a python script to be launched from a terminal. Then connect to your board with ssh, create file with the following code and start it with the command  “python”. Read data now.

import serial
     print "Trying..."
     arduino = serial.Serial('/dev/ttyATH0',230400)
     print "Failed to connect on"
while True:
     print x

Referral link: 

Sharp Dust Sensor GP2Y1010AU
Sharp Dust Sensor Sample Code