Dust sensor reading 0

I have a GrovePi+ attached to my Raspberry Pi 3 B+
With the dust sensor attached to D2 (nothing else plugged in) I get a reading for the first loop or two of the Python script, but all subsequent readings are 0. Other analog and I2C sensors work fine.

I updated to version 1.3.0 of the firmware.
I had to modify the script to change DustSensorRead to dust_sensor_read for it to work at all.

I am using stock Raspbian. I’ll switch to Raspbian for Robots if necessary, but it would be nice if I could get it working in place.

Here is the result of all_tests.sh. Contrary to what it says, I do have WiringPi installed (from apt) and there’s nothing in the blacklist.

=============================
GrovePi Troubleshooting Script
=============================

Adding permissions to the scripts
=================================

Check space left
================
Filesystem      Size  Used Avail Use% Mounted on
/dev/root        30G  2.2G   26G   8% /
devtmpfs        460M     0  460M   0% /dev
tmpfs           464M     0  464M   0% /dev/shm
tmpfs           464M  6.2M  458M   2% /run
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           464M     0  464M   0% /sys/fs/cgroup
/dev/mmcblk0p1   44M   23M   22M  51% /boot
tmpfs            93M     0   93M   0% /run/user/1001

Check for dependencies
======================
python 2.7.13-2 install ok installed
python-pip 9.0.1-2+rpt2 install ok installed
git 1:2.11.0-3+deb9u4 install ok installed
libi2c-dev 3.1.2-3 install ok installed
python-serial 3.2.1-1 install ok installed
python-rpi.gpio 0.6.5~stretch-1 install ok installed
i2c-tools 3.1.2-3 install ok installed
python-smbus 3.1.2-3 install ok installed
arduino 2:1.0.5+dfsg2-4.1 install ok installed
minicom 2.7-1.1 install ok installed
dpkg-query: no packages found matching scratch

wiringPi Not Found (ERR)
I2C still in blacklist (ERR)
SPI still in blacklist (ERR)


Check for addition in /modules
==============================
I2C-dev already there
i2c-bcm2708 already there
spi-dev already there


Hardware revision
=================
gpio version: 2.46
Copyright (c) 2012-2018 Gordon Henderson
This is free software with ABSOLUTELY NO WARRANTY.
For details type: gpio -warranty

Raspberry Pi Details:
  Type: Pi 3+, Revision: 03, Memory: 1024MB, Maker: Sony
  * Device tree is enabled.
  *--> Raspberry Pi 3 Model B Plus Rev 1.3
  * This Raspberry Pi supports user-level GPIO access.


Check the /dev folder
=====================
i2c-1
spidev0.0
spidev0.1
ttyAMA0

USB device status
=================
Bus 001 Device 004: ID 0424:7800 Standard Microsystems Corp.
Bus 001 Device 003: ID 0424:2514 Standard Microsystems Corp. USB 2.0 Hub
Bus 001 Device 002: ID 0424:2514 Standard Microsystems Corp. USB 2.0 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=dwc_otg/1p, 480M
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/4p, 480M
        |__ Port 1: Dev 3, If 0, Class=Hub, Driver=hub/3p, 480M
            |__ Port 1: Dev 4, If 0, Class=Vendor Specific Class, Driver=lan78xx                                                                                                                                                                             , 480M
Raspbian for Robots Version
===========================
cat: /home/pi/di_update/Raspbian_For_Robots/Version: No such file or directory


Hostname
========
airquality


Checking for Atmega chip
========================


avrdude: Version 5.10, compiled on Jun 18 2012 at 12:38:29
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "/etc/avrdude.conf"
         User configuration file is "/root/.avrduderc"
         User configuration file does not exist or is not a regular file, skippi                                                                                                                                                                             ng

         Using Port                    : unknown
         Using Programmer              : gpio
         AVR Part                      : ATMEGA328P
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                                                                                                                                                                                                    Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  Max                                                                                                                                                                             W   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ---                                                                                                                                                                             -- ---------
           eeprom        65     5     4    0 no       1024    4      0  3600  36                                                                                                                                                                             00 0xff 0xff
           flash         65     6   128    0 yes     32768  128    256  4500  45                                                                                                                                                                             00 0xff 0xff
           lfuse          0     0     0    0 no          1    0      0  4500  45                                                                                                                                                                             00 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  4500  45                                                                                                                                                                             00 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  4500  45                                                                                                                                                                             00 0x00 0x00
           lock           0     0     0    0 no          1    0      0  4500  45                                                                                                                                                                             00 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0                                                                                                                                                                                  0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0                                                                                                                                                                                  0 0x00 0x00

         Programmer Type : GPIO
         Description     : Use sysfs interface to bitbang GPIO lines

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e950f
avrdude: safemode: lfuse reads as FF
avrdude: safemode: hfuse reads as DA
avrdude: safemode: efuse reads as 5

avrdude: safemode: lfuse reads as FF
avrdude: safemode: hfuse reads as DA
avrdude: safemode: efuse reads as 5
avrdude: safemode: Fuses OK

avrdude done.  Thank you.


Checking I2C bus for devices
============================

Checking I2C bus 0
==================
Error: Could not open file `/dev/i2c-0' or `/dev/i2c/0': No such file or directo                                                                                                                                                                             ry

Checking I2C bus 1
==================
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- 04 -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

Checking for firmware version
=============================
GrovePi has firmware version: 1.3.0

Hi @volpeandrew,

This is so odd as this is the first time hearing a problem with the 1.3.0 version of the GrovePi. And what’s even weirder is that I have already fixed this.

Anyhow, since this is super important, I’ll have the dust sensor checked again on this version and I’ll come back with an answer.


As for

I had to modify the script to change DustSensorRead to dust_sensor_read for it to work at all.

Can you show me exactly what you did?


WiringPi shouldn’t present itself as being a problem.

Thank you!

Regarding having to change a file - grove_dust_sensor.py - there’s a line reading

[new_val,lowpulseoccupancy] = grovepi.DustSensorRead()

I got an error saying that grovepi didn’t have such a function. Looking at grovepi.py I saw that the function is in fact dust_sensor_read so I modified grove_dust_sensor.py to match. All files in /home/pi/Dexter etc… were originally pulled down with the regular installation script but I ran your beta script (https://raw.githubusercontent.com/RobertLucian/GrovePi/fix/firmware-bugs/Script/update_grovepi.sh) without erasing the existing directory so maybe there’s some file version mismatches?

Small update - perhaps I was being impatient. The 0 readings are not going forever, I do get positive values at some point. For example, after leaving the script running for a while (the non zero readings started much sooner this time), I got:

89
0
0
0
0
38
127
0
0
41
36
0
0
42
428
0
44
88
0
0
0
38
0
0
0
0
0
0
124
0
45
16711680
0
45
0
0
0
89
48
0
0
41
0
0
0
0
0
0
0
0
0
0
0
0
0
43
39

Are the strings of zeros expected behavior? If so I may not have an issue afterall.

Hi @volpeandrew,

Okay, haven’t had much time to look at it since we had the winter holidays (Christmas and the New Year). I’ll look at this tomorrow and I’ll be back with an answer.

Thanks!

Hi @volpeandrew,

I have tested it on mine and it seems to be fine, apparently. I generally get these kind of values from grovepi.dust_sensor_read function.

[1, x]
[0, x]
[0, x]
[0, x]
[0, x]
[0, x]
[0, x]
[0, x]
[0, x]
[1, y]
[0, y]
[0, y]
[0, y]
[0, y]

and so on, where x and y are non-negative integers. The time difference between the moments the 1st element of the list is 1 is exactly the interval set for the dust sensor, which by default it’s set to 30 seconds (as described in the documentation).

So, yes, getting zeros in-between readings is normal, but I’m not entirely sure this is your case. To figure this out, I have 2 questions for you:

  1. Where do your values come from? Are those the 2nd element of the list returned by grovepi.dust_sensor_read function?

  2. Is the timing between each value that you get back the same? Like is your function called after a specific time?

One way to be sure you’re getting non-negative numbers from the sensor is to manually obturate the sensor with something as simple as a piece of paper. You will still get zeros with the read function, but you’re only going to get them when they are supposed to appear - namely within the time window of the sensor’s readings.

From the documentation:

Returns : {(Integer, Integer)} list - the 1st element is 1 if the read value is a new one or 0 if it’s old and the 2nd element holds the actual LPO (low pulse occupancy) time.

Let me know how it went for you.

Thank you!