Dust Sensor fails during access to other ports

Hi GrovePi enthusiats,

I came across a problem with my dust sensor and wonder whether this is “by design” or a mistake in my code.

A python script accesses the dust sensor through:

[lpo, percent, concentration] = grovepi.dust_sensor_read_more()

From time to time the script hangs while executing this command. I need to close the script and re-run it. During my troubleshooting session I discovered that this problem only exists if the command is executed and in the meantime some other processes perform a command (e.g. digitalWrite(led,1)) to another port.

I have two questions:
1.) Is this by design? I already developed a different solution which takes care that there is no parallel activity ongoing but would like to stick to my “older” approach.
2.) Is there a way to abort the grovepi.dust_sensor_read_more() with a timeout if it fails?

Thanks,
Adrian

That’s with the old version of the firmware, 1.3.0. In 1.4.0 we went back to the old approach of just returning you a result, whether that is valid or not.

Yes, that was by design - it was designed to hang until a valid response came back from it. Although there was still available a non-blocking function called dust_sensor_read.

Anyhow, here’s the latest documentation of the firmware’s API for the dust sensor:
https://dexterind.github.io/GrovePi/api/interrupt/#grovepidust_sensor_readpin-2-period-30000

Let me know if that’s good enough for you.

Thank you!