Hi,
I have done the course (V1.3). I love the really very well written tutorial and course. I have completed the project as described from page 304, MQTT with Node Red and DS18B20. Worked very well from the onset however after some time (can be more than an hour or shorter) the ESP stops sending temperature data and I see a CRC error in the Thonny shell window.
I’m also seeing “0” readings every so often. I have changed the sensor and also adjusted the intervall from the initial 5 seconds to different values but still the same.
What might be the reason?
Hans
I’ve added a snapshot of the error after about 30 minutes
Found DS devices: [bytearray(b'(^}\xf7C \x01\x1f’)]
Temperatures:
23.875 Valid temperature
Published: b’23.9′
Found DS devices: [bytearray(b'(^}\xf7C \x01\x1f’)]
Temperatures:
23.875 Valid temperature
Published: b’23.9′
Found DS devices: [bytearray(b'(^}\xf7C \x01\x1f’)]
Temperatures:
23.875 Valid temperature
Published: b’23.9′
Found DS devices: [bytearray(b'(^}\xf7C \x01\x1f’)]
Temperatures:
Traceback (most recent call last):
File “main.py”, line 50, in <module>
File “main.py”, line 10, in read_ds_sensor
File “ds18x20.py”, line 40, in read_temp
File “ds18x20.py”, line 30, in read_scratch
Exception: CRC error
MicroPython v1.18 on 2022-01-17; ESP32 module with ESP32
Type “help()” for more information.
MicroPython v1.18 on 2022-01-17; ESP32 module with ESP32
Type “help()” for more information.
>>>
Hi.
I found this suggestion: https://forum.micropython.org/viewtopic.php?f=16&t=2564&sid=0aaedba78f89641e442f8ec90438e620&start=10
In that case, the error happens in a different scenario. But the suggestion might work for your case. If you add an error handling routine as described, the code will not crash and will proceed to the other sections of code when the issue is solved.
Regards,
Sara
Hi Sara,
thanks for your response. I’ve done more tests and research and ultimately modified the code and using Robert-hh’s drivers The assert raising the CRC error is in onewire.py. That is caught in DS18B20.py (both are loaded to the ESP32) and I can deal with the AssertionError. I can disconnect the sensor and reconnect and don’t break the code. The original ds18x20.py would not deal with a CRC error.
Many thanks again for the lead.
Hans
Hi.
That’s great. Definitely a better option.
I’ll mark this issue as resolved. If you need further help, you just need to open a new question in our forum.
Regards,
Sara
Thanks Sara.
I think some of these issues also stem from very different and varying qualities of the DS18B20 sensor, especially the CRC error. I tried several of them and don’t even use long leads. Just breadboard assembly.
The original MicroPython driver is not having a lot of options for error handling.
Hans