Dust Sensor in Python

Hi

I’m having difficulties getting my Grove Dust Sensor to take any readings. I run the dust sensor code from https://github.com/DexterInd/GrovePi/blob/master/Software/Python/grove_dust_sensor.py on my pi 3 with grove pi plus but it just outputs “reading from the dust sensor” on the command line, with no readings (left it running for about 15 mins to give it time to warm up). The Python code for the sensor is quite short so I’m not sure where it is going wrong. Has anyone got any debugging tips or tests that would be worth trying to narrow down where the problem might be?

Any help or pointers would be greatly appreciated!

Many thanks

Graham

Hey Graham,
You might need to update the firmware to 1.2.4 to get the sensor to work. Can you follow the instructions here and see if it works for you.

-Karan

Hi Karan

Thanks for the reply. Have you got the link to the instructions you refer to please?

Many thanks

Graham

Sorry, I missed adding the link. Here is the link to the other forum post where the firmware update process is give.

-Karan

Hi, I seriously can use some help! I have purchased a GrovePi and dust sensor for my daughter’s science fair, but I can’t get it to work. I have got to get some data for my daughter to tabulate and really need some help.

I have read through all of the Dexter forums, installed what I believe are the updates to the firmware, but when I try to run the python dust sensor package, I get error messages. Should I delete everything and start over?

Thank you in advance for any help you can provide!

@hallberg.brad,
We’ll help you out getting the dust sensor to work. Can you tell us which image are you using and what all have you tried. Which example did you try running. To which port were you trying to connect the sensor. What all sensors do you have with you. Can you post a few pictures of your setup.

Hi Karan, thank you for the fast follow up! Below is a picture of my setup. I am using a Raspberry Pi 2 with Raspbian Pixel OS. I have the sensor plugged into D8. I do not hear the sensor, or feel a vibration while it is connected (not sure if this is important).

I have followed the advice you have given on other Dexter threads, as well as this current discussion, and updated my GrovePi firmware from GitHub to the current version.

Also, using SSH, I have run a test just his morning and here is what I saw:

BEGIN
pi@raspberrypi:~/Desktop/GrovePi/Software/Python $ sudo python grove_dust_sensor.py
Reading from the dust sensor
0
0
0
END

It appears my sensor is detected by the Pi and getting some reading. I wonder if my Dust Sensor is in the optimal position to collect data?

Thank you so much for your help! If I can get a few reading for my daughter I will be her hero! :slight_smile:

@hallberg.brad,
Can you try using our Raspbian for Robots image, installation guide here. It is based on Raspbian and we have optimized it for our products and for ease of use. Can you run this script and let us know what it shows.

The sensor is an optical sensor you wont hear or see anything when it is working. We’ll try our best to get this working ASAP

Hi Karan, so I got a new SD card and loaded Raspbian for Robots by following the link you provided. I have also updated the entire directory.

Also, I have checked the firmware and got the following response:
pi@dex:~/GrovePi/Software/Python $ sudo python grove_firmware_version_check.py
GrovePi has firmware version: 1.2.7

I attempted to operate the Dust Sensor plugged into GrovePi port D8 and received the following data:
pi@dex:~/GrovePi/Software/Python $ sudo python grove_dust_sensor.py
Reading from the dust sensor
0
0
Error
0
0
0
0

I feel like I should be getting something other than "0’.

Thank you again for helping me along. The science fair data is due this Friday so hopefully we can figure this out and start our collection process.

@hallberg.brad,
I am not really sure what is going wrong with the sensor. When and from where did you buy it from. Can you run the example for ~5 mins and see if the values change.

Can you try rolling back to an older firmware and check if it works for you. Goto this folder on the pi:

GrovePi/Firmware/Source/v1.2/grove_pi_v1_2_2

and run :

avrdude -c gpio -p m328p -U flash:w:grove_pi_v1_2_2.cpp.hex

after this, run the firmware check script to make sure that you are on 1.2.2 and then try the dust sensor example again to see if it works.

Karan, sorry for the long delay! We swithed up the project in order to meet our deadline. But…I have been able to load the older firware you listed and get data. I burned a small sheet of paper to encourage particles. I have not tried to reload the latest firmware to determine if the issue is the firware, or the sensor, but may do so in the future. For now, I need a break! :slight_smile:

@hallberg.brad,
Great to hear that it owrked for you and really sorry that it took this much of a time to get working. Do send us more information if you use the sensors again.

Hi @hallberg.brad,

Make sure you use our latest firmware 1.2.7, if you dont have it then you can run sudo python /home/pi/Desktop/GrovePi/Firmware/firmware_update.sh. Please have your Dust sensor connected to Port D2, it works only on this port and we have changed the documentation here. Thanks a lot for bringing it to our notice, please let us know if this helps.

-Shoban

Hello All,

It seems using Firmware 1.2.7 on the official image for GrovePi still does not work on the Dust Sensor.
I contacted support who told me it would work with the Raspberry Pi and GrovePi+ before I purchased it.
I don’t even get zero values returned when running the line:
sudo python grove_dust_sensor.py

I only get one line printed which is “Reading from the dust sensor”.

No other values have printed on screen in nearly 15 minutes.
I have tried to use both D8 port which documentation said to use, and D2 port which the python code had commented to use. Neither appear to work.

I am using a Raspberry Pi 3 with the newer GrovePi+ board that support Windows IoT. I am using lynux.

I have seen many posts with this issue which all seem to eventually get resolved. But none of their solutions have worked yet. I have spent about 3 hours diagnosing this now with the latest attempt coming up on 20 minutes run time on port D2.

Thank you for your help.

Cheerio,
Cormac

Hi @dctoday,

I’ve also got firmware version 1.2.7 on my GrovePi + Raspberry Pi 3 duo it seems to be working.
Take a look at the following reply I came up from another thread. Is that the script you’re also calling?

Note: Click on the down-looking arrow around the quoted text to see the full answer from that other thread

Thank you!

Hi @RobertLucian,

Thank you for your reply.
Unfortunately it still does not work. Also yes I’m using the default script that’s provided.
I’m baffled at how to proceed? @Shoban, can dexter industries provide any advice please?

Cheerio,
Cormac

May I also add this issue link where it seems the bug tag was removed but the issue never resolved as firmware 1.2.7 is the latest. I just tried updating it there and it confirmed this.

Just to add that when I downgraded the firmware to 1.2.6 I was then getting readings but a lot of zeros would appear among the values when running the default grove_dust_sensor.py script.

Yet no values would loud if trying to run another script I have that pulls data from multiple sensors, so I downgraded to firmware 1.2.5 but alas to no avail.

I have come across this which also seems relevant: GrovePi analog sensors fail with dust sensor [NOT SOLVED]

So it seems this dust sensor has been poorly tested for the GrovePi+ given the level of issues that not only me but the dozens of websites I’ve come across online have detailed.

Hey @dctoday I wanted to hop in here. I setup Raspbian for Robots on a Pi 3, updated the firmware:
~/Dexter/GrovePi/Firmware $ sudo bash firmware_update.sh
and ran the dust sensor example:
~/Dexter/GrovePi/Software/Python $ sudo python grove_dust_sensor.py
and also received normal readings.

image

A few things to double check:

  • This is the example program.
  • The example runs on the D2 port.
  • The example takes only 30 seconds to run.
  • I am using the Grove Dust Sensor. To be clear, that’s part number SEN12291P.

A little more on the dust sensor: it’s labeled PPD42 and here’s a picture
DSC_2534

If you’re sure you’re doing exactly the same thing, using the same sensor I would do the following:

  1. Check that the GrovePi+ is working properly. You can run the command sudo python grove_firmware_version_check.py and you should see a valid firmware version (mine is 1.2.7).
  2. If that works and you get a good response, your GrovePi is fine and it’s a problem with the sensor.
    Contact Seeed for a replacement sensor.

Hi @JohnC,

Thank you for your reply.
I upgraded the firmware back to 1.2.7 and plugged only the Dust Sensor into D2. (We bought multiple so I know the sensor is not faulty)
My readings were then as below which looks much better:
5052
31
260
189
362
302
etc…

The issue it seems is that I had setup all sensors and then ran scripts against each one and then ran a combined script which is failing to give unique results.

My setup:
Raspberry Pi 3 (Model B)
GrovePi+ (Windows IoT Version)
Firmware 1.2.7
Operating System official dexter image fully updated
http://wiki.seeed.cc/Grove-Temperature_and_Humidity_Sensor_Pro/ - Digital – D4

http://wiki.seeed.cc/Grove-Water_Sensor/ - Digital – D3

http://wiki.seeed.cc/Grove-Air_Quality_Sensor_v1.3/ - Analogue – A0

http://wiki.seeed.cc/Grove-Gas_Sensor-MQ2/ - Analogue – A1

http://wiki.seeed.cc/Grove-Gas_Sensor-MQ9/ - Analogue – A2

http://wiki.seeed.cc/Grove-Dust_Sensor/ - Digital – D2

Are you able to replicate my setup and see if you run into the same issues please?