Interacting with a Sharp GP2Y1010 dust sensor

Hi Yall.

I’m trying to talk to a sharp GP2Y1010 dust sensor, using the existing dustsensor grove functions, which I’m guessing aren’t really what I need.

There’s precious little documentation about how it all works, I’m assuming the calls to the grove’s arduino kick off some polling, and return something from the arduino… but I’ve not quite sorted out what’s what.

I’ve bolted logging through the logger module into the grovepi.py script in the relevant functions to be able to get data out… and tried uncommenting the i2c funcs in the dustSensorRead func, as well as trying the existing bus route… here’s what I see:

2016-09-22T13:05:10.562Z <getDust> DEBUG: dust0 [GP2Y10] (8)  0: Initializing the dust sensor -1 5
2016-09-22T13:05:10.563Z <Grove.grovepi.dust_sensor_en> DEBUG: calling write_i2c_block with: address 4, [14, 0, 0, 0]
2016-09-22T13:05:10.769Z <getDust> DEBUG: dust0 [GP2Y10] (8)  0: inloop
2016-09-22T13:05:10.769Z <Grove.grovepi.dustSensorRead> DEBUG: calling write_i2c_block with: address 4, [10, 0, 0, 0]
2016-09-22T13:05:10.974Z <Grove.grovepi.dustSensorRead> DEBUG: using i2c funcs, we got this back: read_i2c_byte: 0 read_i2c_block: [0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]
2016-09-22T13:05:10.978Z <getDust> WARNING: dust0 [GP2Y10] (8)  0: Didnt get a value. Incrementing error.
2016-09-22T13:05:10.978Z <getDust> DEBUG: dust0 [GP2Y10] (8)  1: inloop
2016-09-22T13:05:10.979Z <Grove.grovepi.dustSensorRead> DEBUG: calling write_i2c_block with: address 4, [10, 0, 0, 0]
2016-09-22T13:05:11.184Z <Grove.grovepi.dustSensorRead> DEBUG: using i2c funcs, we got this back: read_i2c_byte: 0 read_i2c_block: [0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]
2016-09-22T13:05:11.188Z <getDust> WARNING: dust0 [GP2Y10] (8)  1: Didnt get a value. Incrementing error.
2016-09-22T13:05:11.189Z <getDust> DEBUG: dust0 [GP2Y10] (8)  2: inloop
2016-09-22T13:05:11.189Z <Grove.grovepi.dustSensorRead> DEBUG: calling write_i2c_block with: address 4, [10, 0, 0, 0]
2016-09-22T13:05:11.394Z <Grove.grovepi.dustSensorRead> DEBUG: using i2c funcs, we got this back: read_i2c_byte: 0 read_i2c_block: [0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]
2016-09-22T13:05:11.398Z <getDust> WARNING: dust0 [GP2Y10] (8)  2: Didnt get a value. Incrementing error.
2016-09-22T13:05:11.399Z <getDust> DEBUG: dust0 [GP2Y10] (8)  3: inloop
2016-09-22T13:05:11.399Z <Grove.grovepi.dustSensorRead> DEBUG: calling write_i2c_block with: address 4, [10, 0, 0, 0]
2016-09-22T13:05:11.604Z <Grove.grovepi.dustSensorRead> DEBUG: using i2c funcs, we got this back: read_i2c_byte: 0 read_i2c_block: [0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]
2016-09-22T13:05:11.608Z <getDust> WARNING: dust0 [GP2Y10] (8)  3: Didnt get a value. Incrementing error.
2016-09-22T13:05:11.608Z <getDust> DEBUG: dust0 [GP2Y10] (8)  4: inloop
2016-09-22T13:05:11.609Z <Grove.grovepi.dustSensorRead> DEBUG: calling write_i2c_block with: address 4, [10, 0, 0, 0]
2016-09-22T13:05:11.814Z <Grove.grovepi.dustSensorRead> DEBUG: using i2c funcs, we got this back: read_i2c_byte: 0 read_i2c_block: [0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]
2016-09-22T13:05:11.818Z <getDust> WARNING: dust0 [GP2Y10] (8)  4: Didnt get a value. Incrementing error.
2016-09-22T13:05:11.818Z <getDust> DEBUG: dust0 [GP2Y10] (8)  5: Disconnecting the dust sensor
2016-09-22T13:05:11.819Z <Grove.grovepi.dust_sensor_dis> DEBUG: calling write_i2c_block with: address 4, [15, 0, 0, 0]
2016-09-22T13:05:12.020Z <parseDust> DEBUG: dust0: {'raw': -1, 'error': 5, 'IOerror': 0}

the dust sensor is attached to digital 8 on the grovepi, because I saw on some blog that this is the only supported port for the dust sensor.

Can anyone help me sort out what to do properly here?
I’ve been using these for reference:

#https://github.com/DexterInd/GrovePi/blob/master/Software/Python/grove_dust_sensor.py
#http://www.pocketmagic.net/sharp-gp2y1010-dust-sensor/

Hi @grovepi1,

Can you please refer to this discussion and try out the solutions given there and do tell us if it works for you.

-Shoban

Hi Shoban,

Thanks for the pointer, however that’s referencing the stock ‘grove’ dust sensor, which appears to be a different beast entirely… I thought it would be confusing to try to conflate the issues, as my issue is likely that I need to perform an analog read, not a digital one, to get the data from the sensor in question.

if you look at the schematic Radu in the link above

The 6 pins exposed by GP2Y1010AU0F, must be connected as follows:
White pin 1 (V-LED) => connected through a 150ohm resistor to the Vcc (3.3V)
Blue pin 2 (LED-GND) => GND
Green pin 3 (LED) => atmega128 I/O port
Yellow pin 4 (S-GND) => GND
Black pin 5 (Vo) => atmega128 ADC port
Red pin 6 (Vcc) => Vcc (3.3V)
The datasheet indicates using a 150Ohm resistor between pin 1 (white, V-LED) and Vcc (3.3V), and a 220uF capacitor . These are optional, since the device will work fine and with the same output when PIN 1 is connected directly to VCC (without resistor), and the capacitor is omitted.

This lead me to wire the sensor connected to port D8 on the grovePi seemed like what I should do…

I was referencing this page:
www.dexterindustries.com/GrovePi/engineering/port-description/

But after looking at the above repeatedly, and then looking at the firmware source: (grove_pi_v1_2_6.ino#L831 )
the grovePi is doing pwm from D8 to the grove dust sensor…

and the sharp sensor seems to need to be read analog… (this just dawned on me as I was rubberducking here)

so I think I really ned to be reading the dust sensor on an analog port. Fortunately, it looks like I can steal A3 from the second wire on the A2 plug, and use that to read. I’ll try this now and see what happens.

Hi @grovepi1,
Sorry, we thought that it was the same sensor. I just looked up the sensor and indeed its a completely different sensor. Sparkfun had a little more information and pointers on how to use that sensor and I found some sample arduino code for it too.

The Grove sensor is a bit simpler than this one. All it does is send a pulse once in 30 seconds which indicates the dust in PPM. This one seems to require a lot of other things too, especially setting up some digital pins first and then take an analog reading once the digital pin toggles.

It is not supported by the GrovePi right now but the functionality can be added to it with a lot of effort on the software side, I would recommend you to use an Arduino or have a look at Arduberry which would be a lot more easier to get the data from this.

-Karan

Hi Karan,

(Tangent: Is there a way to change my username? it picked the name out of my reg’d email… I wouldn’t want to be mistakenly affiliated with grove by others)

I’m gonna try just wiring the LED hot and see if I get anything consistent off the analog sensor reading. If not, I’ll look for another good quality dust sensor, that simply has an analog, or pwm input.

another tangent, before I do it, would you guys be opposed to a PR for the py codebase which utilizes the logging python module to make it a little easier to diagnose what’s getting to where?

And here I was thinking you liked the GrovePi so much that you ended up using it as your username. To change your username, goto your account preferences (which should be at the top right under G+ icon having your profile picture, then goto the Preferences Tab and edit the username)

Do let us know if the sensor works for you. The only dust sensor that we have tried is the one in the Grove system and even that was very hard to use. Do let us know if you are able to find a good dust sensor which gives output which is simple enough to read. There is a nice writeup about the dust sensor here which explains things a bit better.

A lot of the software for the GrovePi has actually been developed by the community and we always look forward to more pushes from the community. We’ll review the pull request though just to make sure that it doesn;t break anything.


Not editable :frowning:

'salgood though. I do like the product :wink: I just don’t want others to think I represent y’all.

I’ll have a PR soonish. are there any known weirdnesses with the .6 firmware and multiple DHT devices?

Oh, looks like only admin have that feature. We have just moved to the new forums so didn’t know that. Is it fine if I change your username and what would you like the username to be.

I don;t remember having an issue with multiple DHT sensors but if you are having an issue with them, can you open another post and we’ll have a look at it and try to solve the problem.

Wolfspyre, Please :slight_smile:

sorry for the hassle.

Is there a member access level I have to be to be able to send direct messages?

Just changed you username. Not really sure about the access level required to send messages. Can you go to the messages section and see if you can send messages.