Dust Sensor no reading - Firmware 1.3.0

grovepi
dust-sensor

#1

I upgraded the firmware to v1.3.0. Earlier I was getting readings of 1 or 0 or Error in the v1.2.7 version.(connected dust sensor to D2 )

Now there are simply no readings at all.

Since 1.2.5 I do not think the sensor worked on any of the versions. Is there a solution? Or is my sensor itself faulty?


#3

Hi @reunny,

I’ve just tested it on mine and it’s working perfectly. Maybe you’re still running a script that’s not up to date. Here’s how I did it:

import grovepi
import time

grovepi.dust_sensor_en() # it enables it on port D2
grovepi.set_dust_sensor_interval(10000) # set it to retrieve the values every 10 seconds

while True:
    read, lpo_time = grovepi.dust_sensor_read()
    if read == 1:
        print('LPO time = {}'.format(lpo_time))
    time.sleep(2)

And this is what I’m getting in return from it:

LPO time = 30
LPO time = 421
LPO time = 256
LPO time = 230
LPO time = 0
LPO time = 78
LPO time = 160
LPO time = 383
LPO time = 16
LPO time = 697
LPO time = 1939
LPO time = 855
LPO time = 639

If you look at the script, you’ll see that before using the dust sensor, I had to enable it, otherwise, it will only return zeros. The 2nd instruction, for setting the sensor interval to 10s is because the default one is at 35 seconds and that was a bit too much for what I needed to showcase.

And if you want to connect a different device to that port, you’ll consequently have to disable the dust sensor by calling dust_sensor_dis. You can check more about this here:
https://dexterind.github.io/GrovePi/api/interrupt/

Let me know if that made your dust sensor device to work.

Thank you!


Error in Grove Dust Sensor code (Solved)