Circuit check for noob

Yes that is better.

Dust detector? I married one of those. :slight_smile:

I married one of those.

Cool, does she on on 3.3V or 5V :slight_smile:

Thanks for the confirmation Mike, appreciated. The first circuit shown caused problems with the I2C sensor I also have connected, I guess the second (correct) circuit should avoid this problem? I think the 150R resistor was effectively shorting the power?

Cool, does she on on 3.3V or 5V :slight_smile:

What?

Yes the first circuit essentially put a load of 22mA across the supply so not exactly shorting but did nothing about the decoupling.

The first circuit shown caused problems with the I2C sensor

Is it connected to a 5V arduino? if so then you have to disable the pull up resistors in the wire library and add your own 2K2 pull ups to 3V3.

The arduino is 3.3V, I have the SCL & SDA pulled high (3.3V) via two 4K7 resistors but have not disabled internal pullups through the wire library (how do I do that please?). The I2C bus and dust sensor would be powered by the same 3.3V line, hoping this will work out?

Yes that should be fine. Good luck.

Thanks again Mike, sounds like I won't need to worry about turning the internal pullups off if I'm using external 4K7 pullups?

OK, so I have my circuit complete and code installed but I don't seem to be getting sensible output..... wondering if anyone can spot any obvious blunders?

My reference is here: http://sensorapp.net/?p=479 I have changed pin assignments as per the circuit below and the voltage used is 3V3 rather than 5V but the sensor can handle this I believe. I'm not sure what this line is doing: pinMode(4, OUTPUT);

Any clues or thoughts appreciated.

My code is:

int dustPin=1;
int dustVal=0;

int ledPower=6;
int delayTime=280;
int delayTime2=40;
float offTime=9680;
void setup(){
Serial.begin(9600);
pinMode(ledPower,OUTPUT);
pinMode(4, OUTPUT);
}

void loop(){
// ledPower is any digital pin on the arduino connected to Pin 3 on the sensor
digitalWrite(ledPower,LOW); // power on the LED
delayMicroseconds(delayTime);
dustVal=analogRead(dustPin); // read the dust value via pin 5 on the sensor
delayMicroseconds(delayTime2);
digitalWrite(ledPower,HIGH); // turn the LED off
delayMicroseconds(offTime);

delay(3000);
Serial.println(dustVal);
}

digitalWrite(ledPower,LOW); // power on the LED

Will actually turn OFF the LED, not on.

Why are you running it off 3v3? This will make the 150R cut down the LED current more than is anticipated.

Why all the talk about I2C earlier on?

Hi Mike,

The LED seems to use a PNP transistor so to power on, the LED pin must actually recieve a lower voltage.

I'm running this off 3V3 as that is the native logic voltage of my board - perhaps I should change the resistor value... would this simply be 3.3/5 X 150 = 100?

The I2C talk was related to the I2C circuit which shares the VCC with this circuit.

The LED seems to use a PNP transistor

Yes but when I looked at the circuit in the link you gave I saw a FET and thought it was part of the circuit. Sorry.

I have now looked at the data sheet and noticed that there is an amplifier in front of the detector. I also notice that it says recommended operating voltage 5V. That suggests to me that the amplifier needs 5V to work and that it won't work correctly on 3V3. There are a lot of op-amps that will work off 5V and not 3V3.

perhaps I should change the resistor value... would this simply be 3.3/5 X 150 = 100?

No not that simple because you have the forward volts drop of the diode and the saturation voltage of the transistor to consider.

I would try and get it to work on 5V first and cut the output down with a potential divider.

Well, better at 5V but still a bit odd in terms of output.... see below - all or nothing rather than the steady change that one might expect? That said - this setup: http://itp.nyu.edu/physcomp/sensors/Reports/GP2Y1010AU seems to be getting a similar result..... the datasheet shows a more steady ramp on the dust/mV graph.

2
2
2
726
727
727
727
2
2
2
3
2

Thinking about it that might be what you expect. The large numbers are when there is a response value of dust and when the dust wasn't there you would get a small value. Dust by it's nature is an intermittent phenomenon so maybe taking the maximum values would be more realistic.

OK, I'm going to try this setup over a longer period to see what gives :slight_smile:

To convert the Anaolg pin output may I check the following with you....

Anolog pin input ranges from 0-1024
Sensor range is 0-0.6 mg/m3
This sensor seems to range from 500mV (no dust)
Every 0.1mg of dust = 500mV
So, voltage ranges from 500mV to 3500mV
So max output without remapping is 3500/5000 * 1024 = 717 (pretty much what I saw).
My output in mg/m3 is therefore = ((((dustVal/717)*3500)-500)/500) * 0.1
EG reading on Analog 1 = 412 = 0.3mg/m3

Looks goo to me. :slight_smile:

hello,
i’m experimenting too with GP2Y1010AU0F, but i’ve found a strange behaviour.
my sensor is conncted like datasheet explain, pin 3 direct to atmega (i’ve also try using a mosfet but it do not change)
if i run GP2Y1010AU0F with 5.330 voltage i read an output voltage between 0.800 and 0.850
if i run GP2Y1010AU0F with 5.080 voltage i read an output voltage between 0.770 and 0.830
if i run GP2Y1010AU0F with 4.670 voltage i read an output voltage between 0.700 to 0.770
so there’s a small drift when supply voltage change.
i suppose the fig 3 of datasheet, from which we can extract slope and offset to find dust sensity, it’s 5.0v supply voltage, so reading an “incorrect” voltage would bring to incorrect mg/m^3 conversion.
have you also find this behevior?
have you find a way to balance the supply voltage drift?

thanks all

I think the best option is to run that detector (both the amplifier side and the LED side) from a regulated 5V supply. However, the readings you are getting appear to be roughly ratiometric with the supply voltage. Therefore, if you feed the output into in analog input of an Arduino that is powered from the same 5V supply, then the ADC will approximately compensate for supply voltage variation.

dc42:
I think the best option is to run that detector (both the amplifier side and the LED side) from a regulated 5V supply. However, the readings you are getting appear to be roughly ratiometric with the supply voltage. Therefore, if you feed the output into in analog input of an Arduino that is powered from the same 5V supply, then the ADC will approximately compensate for supply voltage variation.

thank for reply,
my readings are taken from arduino, and checked with multimeter, to get voltage i use bandgap for the adc ref voltage, so it does not compensate reading. to check adc i try the compensation why different voltage using other sensor, or using a simple resistor, and it works!, but this times not; i think is the output of this sensor that change with voltage supply changing, but datasheet unfortunately do not tell anything about sensitivity over voltage.
anyway, i suppose you are right, best option is to run it over regulated 5v power.

Hi, I'm working with an Arduino Uno and Sharp Dust Sensor GP2Y1010AU0F for a project. Is there any official example or test code I can upload while testing it? Any help would be greatly appreciated!

Here is kind of "official" test code for GP2Y1010AU0F connected to Arduino thru waweshare adapter board:
wiki page: http://www.waveshare.com/wiki/Dust_Sensor
code: http://www.waveshare.com/wiki/File:Dust-Sensor-code.7z

Please note, that board inverts voltage to turn infrared led on/off and has signal 1/10 divider.
So to turn-on the ILED you should call digitalWrite(PIN_LED, HIGH); and to switch-off digitalWrite(PIN_LED, LOW);
and you have to multiple value from analogRead(SENSOR_PIN) * 11.
All that info you will find in example. But to be honest this is a bit useless. Anyway you need to programmatically calibrate values received from sensor. Also please keep in mind that Arduino ADC will give you slightly different measurement depending on ambient temperature, according to specification ADC accuracy is +/-10%. If you want to have more precision measurements you have to use external reference voltage to Arduino AREF pin like described here Arduino Tutorials – Chapter 22 – the AREF pin | tronixstuff.com
Here is another example of GP2Y1010AU0F connected thru waweshare adapter: arduinosensor/arduino_sensor_main.ino at master · vlytsus/arduinosensor · GitHub