OneWireError exception
Posted: Sat Aug 15, 2020 9:26 am
Hi all,
I'm using an ESP8266 with a DS18B20 temperature sensor and the OneWire library. I'm trying to handle an exception in the case where the sensor becomes disconnected during runtime.
Without any error handling if I disconnect the sensor and run:
then I see:
If I try to catch the exception, my code looks like:
Then I get:
Looking in the onewire library, the OneWireError exception class is just a "pass". Is this the problem? What is the correct way to handle this error?
I'm using an ESP8266 with a DS18B20 temperature sensor and the OneWire library. I'm trying to handle an exception in the case where the sensor becomes disconnected during runtime.
Without any error handling if I disconnect the sensor and run:
Code: Select all
sensor.convert_temp()
Code: Select all
>>> sensor.convert_temp()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "ds18x20.py", line 19, in convert_temp
File "onewire.py", line 22, in reset
OneWireError:
Code: Select all
try:
sensor.convert_temp()
except OneWireError:
print("Error")
Code: Select all
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
NameError: name 'OneWireError' isn't defined