Dust sensor ( GP2Y1010AU0F ), not working properly.

Hello everyone, before I start explained my issue, english is not my first language, but I'll try to make as many mistakes as possible.

So, I've recently acquired the GP2Y1010AU0F, aka dust sensor. Normally, the sensor has 6 output pins [*attachment] :

  • VCC-ILED
  • GND
  • ILED
  • GND
  • AOUT
  • VCC

The sensor has already a pcb(?) included, which converts all those, to only 4 :

  • ILED pin 12
  • AOUT pin A0
  • GND to GND
  • VCC to 5V

I get this number constantly even if I put a pencil inside de sensor, it just doesnt move. Can someone help ? Thank you !

  • See attachments

original.png

original.png

Post your code, and your wiring please.

I dont know why, but the code was on original post.

Here it is

#include <SPI.h>
 
int measurePin = A0;
int ledPower = 12;
  
float voMeasured = 0;
float calcVoltage = 0;
float dustDensity = 0;
  
void setup(){
  Serial.begin(9600);
  pinMode(ledPower,OUTPUT);

}
  
void loop(){
  
  digitalWrite(ledPower,LOW);
  delayMicroseconds(280);
 
  voMeasured = analogRead(measurePin);
 
  delayMicroseconds(40);
  digitalWrite(ledPower,HIGH);
  delayMicroseconds(9680);
 
  calcVoltage = voMeasured*(5.0/1024);
  dustDensity = 0.17*calcVoltage-0.1;
 

 
  Serial.println("Dust Density:");
  Serial.println(dustDensity);
   

  
  delay(1000);
}

The wiring is as said on the original post.

The output is :

16:39:21.240 -> Dust Density:
16:39:21.285 -> 0.00
16:39:22.271 -> Dust Density:
16:39:22.271 -> 0.00
16:39:23.299 -> Dust Density:
16:39:23.299 -> 0.00
16:39:24.288 -> Dust Density:
16:39:24.288 -> 0.00
16:39:25.287 -> Dust Density:
16:39:25.335 -> 0.00
16:39:26.334 -> Dust Density:
16:39:26.334 -> 0.00
16:39:27.329 -> Dust Density:
16:39:27.329 -> 0.00

Try writting the led HIGH, incase the board maker is using an inverter! Could you post a link to where you bought it, or the datasheet for the breakout.

Found it.

Dust SensorUser ManualWaveshare2V1.4, December2920151.2.Control principle1)Enable the internal infrared emitting diode by setting the pin ILEDto HIGH.2)Wait 0.28ms, then the external controllerstartsto sample the voltage from the pin AOUTof the module. Notes that the output wavewill take 0.28ms to reach steady state after the internal infrared emitting diode is enabled, as Figure 2shows.Figure 2:Sampling timing of output pulse3)There is a periodof 0.04ms for sampling. When finished,set the pin ILEDto LOW to disable the internal infrared emitting diode.4)Calculate the dust concentrationaccording to the relationship between output voltage and dust concentration. For more detailed information, please refer to the relative Demos.Note:Theoutputvoltagehasbeendivided(seeschematic),sothatthevoltagemeasurementshouldx11togettheactualvoltage.

Thanks for you time !

I tried switching

digitalWrite(ledPower,HIGH);
  delayMicroseconds(280);
 
  voMeasured = analogRead(measurePin);
 
  delayMicroseconds(40);
  digitalWrite(ledPower,LOW);

just in case it wasn't inverted, but still got the 0's read. Might be a faulty sensor, but I'll try looking for more information.

I got another code from the web, and the results were much better .
I guess I cant trust a random code I fine (:

Thank you for your time, and be safe .

Do you provide the sensor with enough dust to actually measure something?

Hola amigo, estoy teniendo un problema igual al tuyo, como lograste resolverlo? Yo estoy conectando el sensor a un Lora32 ESP32 V2-1.6. Si me ayudas por favor.

Hello friend, I am having a problem like yours, how did you manage to solve it? I am connecting the sensor to a Lora32 ESP32 V2-1.6. If you help me please.


Hello, I can send you the link of the code that I used. Please notice that different arduinos have different bits of resolution on the GPIO pins, and the values will be different.

Go to https://www.waveshare.com/wiki/File:Dust-Sensor-code.7z and download the .7z file, it has a code inside, try to use it.

Good luck.

Darelg via Arduino Forum <arduino@discoursemail.com> escreveu no dia sexta, 11/06/2021 à(s) 17:26:

1 Like

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.