Rui,
Question from my following thread: Python esp32 course chapter Node-Red, How does one add an additional temp sensor (DS18B20)?
I guess my problem is that my ESP32 gets hung up and stops processing. Charts stop recording and gauges stop. I monitored the serial monitor and got the following:
Found DS devices: [bytearray(b”(‘\xa9\xb3/\x14\x01\xb6″), bytearray(b'(\x89\xa0%0\x14\x01\xf7′), bytearray(b'(\xde[\xae/\x14\x01\xd2′), bytearray(b'(bc*0\x14\x01\xd0’)]
Temperatures:
74.075 Valid temperature
73.5125 Valid temperature
73.5125 Valid temperature
73.85 Valid temperature
Found DS devices: [bytearray(b”(‘\xa9\xb3/\x14\x01\xb6″), bytearray(b'(\x89\xa0%0\x14\x01\xf7′), bytearray(b'(\xde[\xae/\x14\x01\xd2′), bytearray(b'(bc*0\x14\x01\xd0’)]
Temperatures:
74.075 Valid temperature
Traceback (most recent call last):
File “main.py”, line 137, in <module>
File “main.py”, line 125, in <module>
File “main.py”, line 21, in read_ds_sensor
File “ds18x20.py”, line 39, in read_temp
File “ds18x20.py”, line 29, in read_scratch
Exception: CRC error
MicroPython v1.9.4-762-gfa50047bb on 2018-12-28; ESP32 module with ESP32
Type “help()” for more information.
>>
I’ve reproduced this several times with the same message. I’m using the code that you recommended when adding three additional temperature sensors. Any suggestions as to why the ESP32 stops processing and how to fix it?
I’m not sure how to fix that error to be honest, because I’ve only used one sensor at a time.
I would recommend adding an exception in your code that restarts the ESP32 when it encounter an error.
In the last line of the main.py file, can you add another exception like this?
(...) except OSError as e: restart_and_reconnect() except: restart_and_reconnect()
This should solve your problem (it will restart the ESP upon any sort of error).
How often does that error occur to you?