Skip to content

Index Error in _get_reply routine #12

Description

@rgmcleod52

I have your code running on a Raspberry Pi. And for the most part it is working, but occasionally I get an IndexError that kills the program.

The problem occurs in the _get_reply(self) function on this line of the sds011.py file:

 if (sum(d for d in data) & 255 !+ raw[8]:
      return None

What I see on the console is as follows:

Traceback (most recent call last):
File "./Combo_ATH_AIO_Web_Thingspeak.py", line 141, in
pmt_2_5, pmt_10 = get_data()
File "./Combo_ATH_AIO_Web_Thingspeak.py", line 97, in get_data
AQISENSOR.sleep(sleep=False)
File "/home/pi/Combo-AIO-Web-Thingspeak/sds011.py", line 113, in sleep
self._get_reply()
File "/home/pi/Combo-AOI-Web-Thingspeak/sds011.py", line 57, in _get_reply
if (sum(d for d in data) & 255 != raw[8];
IndexError: index out of range

I'm not proficient enough with Python to see what the problem is here, so hoping you (or someone else) can help me with this.

Regards,

rgmcleod52

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions