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