Received IndexError instead of SensorNotReadyError from get_raw_sensor_strings() when reading DS18B20
See original GitHub issueI am having a few DS18B20 sensors connected to raspberry pi zero. From time to time the contents of the file /sys/bus/w1/devices/28.../w1_slave
appears to be empty (not sure why). Hence the contents of the list data
in the method get_raw_sensor_strings()
in file async_core.py
is empty as well. Accessing it raises an IndexError
.
Changing line 65 in file async_core.py
from:
if (
data[0].strip()[-3:] != "YES" or "00 00 00 00 00 00 00 00 00" in data[0]
): # pragma: no cover
raise SensorNotReadyError(self)
to
if (
not data or data[0].strip()[-3:] != "YES" or "00 00 00 00 00 00 00 00 00" in data[0]
): # pragma: no cover
raise SensorNotReadyError(self)
resolves the problem.
Thanks.
PS: I am using version w1thermsensor 2.0.0a1
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
DS18b20 No Longer Working - "List INdex Out of Range"
I just installed them in my project, but now the sensors are not being picked up. The board lights up, so it is...
Read more >python - IndexError DS18B20 Temperature sensor
When I run it as root I get an error (line 9) device_folder = glob.glob(base_dir + '28-000005b89af')[0] IndexError: list index out of range...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve released v2.0.0a2
Thanks for the report. We’ve already fixed that for the non-async version of the code, see #94 .
I’ve made the same change now in the async code and will release asap.