Problems with ds18b20

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
rvinaso
Posts: 1
Joined: Mon Feb 22, 2021 4:53 am

Problems with ds18b20

Post by rvinaso » Mon Feb 22, 2021 5:13 am

Hi my friends I am having a trouble with my sensor ds18b20 and my code, after a few measures, suddenly the program stops and shows:
File ds18x20.py, Line 40 in read_temp
File ds18x20.py, line 30 in read_scratch
Excetpion:crc error

User avatar
jimmo
Posts: 2244
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: Problems with ds18b20

Post by jimmo » Mon Feb 22, 2021 5:25 am

rvinaso wrote:
Mon Feb 22, 2021 5:13 am
Hi my friends I am having a trouble with my sensor ds18b20 and my code, after a few measures, suddenly the program stops and shows:
File ds18x20.py, Line 40 in read_temp
File ds18x20.py, line 30 in read_scratch
Excetpion:crc error
This suggests that there is possibly a wiring issue and messages from the sensor are being corrupted (or possibly there's a timing issue decoding it).

If it only happens occasionally, then maybe just catch the exception and retry:

Code: Select all

try:
  sensor.read_temp()
except:
  ...handle error? Maybe retry?

Post Reply