Wemos and dust sensor example

Sharp’s GP2Y1010AU0F is an optical air quality sensor it is designed to sense dust particles. An infrared emitting diode and a phototransistor are diagonally arranged into this device, to allow it to detect the reflected light of dust in air. It is especially effective in detecting very fine particles like cigarette smoke, and is commonly used in air purifier systems.

gp2y1010au0f

To interface with this sensor, you need to connect to its 6-pin, 1.5mm pitch connector by using mating connector.

 

Specifications:

  • Low Current Consumption (MAX: 20mA)
  • Typical Operating Voltage: 4.5V to 5.5V (MAX: 7V)
  • The presence of dust can be detected by the photometry of only one pulse
  • Enable to distinguish smoke from house dust
  • Dimensions: 1.81 x 1.18 x 0.69” (46.0 x 30.0 x 17.6mm)

 

gp2y1010au0f_diagram_2

 

 

dustdensitycharateristics

Connection

The following connections are used

Sharp pin 1 (V-LED)          =  3.3V this is connected via a 150 ohm resistor
Sharp pin 2 (LED-GND)     =  Wemos GND pin
Sharp pin 3 (LED)             = Wemos pin D2
Sharp pin 4 (S-GND)         = Wemos  GND pin
Sharp pin 5 (Vo)               = Wemos A0 pin
Sharp pin 6 (Vcc)              =  Wemos  3.3V

Refer to this layout diagram

Layout

Resister, R1=150Ω and capacitor, C1=220uF mentioned above is required for pulse drive of the LED of GP2Y1010AU0F. Please use the ones with the above mentioned constants. Without these components, the device does not work.

wemos-and-dust-sensor_schem

Code

[codesyntax lang=”cpp”]

int dustPin = A0; // dust sensor - Wemos A0 pin
int ledPin = D2;    

float voltsMeasured = 0;
float calcVoltage = 0;
float dustDensity = 0;
  
void setup()
{
  Serial.begin(57600);
  pinMode(ledPin,OUTPUT);
}

  
void loop()
{
  digitalWrite(ledPin,LOW); // power on the LED
  delayMicroseconds(280);
  
  voltsMeasured = analogRead(dustPin); // read the dust value
  
  delayMicroseconds(40);
  digitalWrite(ledPin,HIGH); // turn the LED off
  delayMicroseconds(9680);
  
  //measure your 5v and change below
  calcVoltage = voltsMeasured * (3.3 / 1024.0);
  dustDensity = 0.17 * calcVoltage - 0.1;
  Serial.println("GP2Y1010AU0F readings"); 
  Serial.print("Raw Signal Value = ");
  Serial.println(voltsMeasured); 
  Serial.print("Voltage = ");
  Serial.println(calcVoltage);
  Serial.print("Dust Density = ");
  Serial.println(dustDensity); // mg/m3
  Serial.println("");
  delay(1000);
}

[/codesyntax]

 

Testing

This is the output that I saw via the serial monitor

GP2Y1010AU0F readings
Raw Signal Value = 6.00
Voltage = 0.03
Dust Density = -0.10

GP2Y1010AU0F readings
Raw Signal Value = 176.00
Voltage = 0.86
Dust Density = 0.05

GP2Y1010AU0F readings
Raw Signal Value = 97.00
Voltage = 0.47
Dust Density = -0.02

GP2Y1010AU0F readings
Raw Signal Value = 7.00
Voltage = 0.03
Dust Density = -0.09

 

Link

Datasheet – http://www.sharp-world.com/products/device/lineup/data/pdf/datasheet/gp2y1010au_appl_e.pdf

GP2Y1010AU0F Compact Optical Dust Sensor Smoke Particle Sensor With Cable

3 COMMENTS

  1. Hi,

    I’ve played around with this sensor using Arduino boards, so it’s interesting to see it used with a Wemos. A few comments…

    1 – It’s a 5v device, so running it from a 3.3v supply does have a significant effect on the output. As you have a 5v pin on the Wemos I’d be inclined to use that.
    2 – Your diagram shows the sensor output connected to D0, this should be A0
    3 – The sensor output range is from about 0.2v up to about 3.6v. but Max input for the Wemos ADC is 1v, so you probably need a voltage divider to scale the sensor output voltage down to under 1.0v
    4 – AnalogRead() on and Arduino takes over 100uS, so affects the timing. Not sure how long it takes on a Wemos – perhaps only 10-20uS with at 80MHz clock. Maybe even less if the prescaler for the ADC is different.

  2. Nick, you right of course… the 1.0v limit is for the esp8266 and the voltage divider is shown on the Wemos schematic. The output of the dust sensor is up to about 3.6v, so perhaps a 47k resistor in series with the A0 input would scale it down so that 3.6v is fractionally under 1.0v at at the ADC.

LEAVE A REPLY

Please enter your comment!
Please enter your name here