DS18B20 error

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
User avatar
Roberthh
Posts: 2462
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: DS18B20 error

Post by Roberthh » Fri Jan 15, 2021 9:18 pm

What I understand: While the above script is running, you disconnect the sensor.

In that case, the read function will read invalid data, obviously with a wrong CRC, and raises a CRC error. That is the expected behavior.
In your script you can catch the CRC error with try/except clause around read.temp(), e.g. as:

Code: Select all

    for rom in roms:
    	try:
            print (ds.read_temp (rom), end = '|')
       except CRCError:
           print("CRC error reading the termperature, unit", rom)
In that case, the script will continue and print error message until you reconnect the sensor.
Obviously, you may implement any reasonable error handling instead.

SirN Check
Posts: 10
Joined: Fri Dec 15, 2017 11:11 am

Re: DS18B20 error

Post by SirN Check » Tue Feb 02, 2021 1:24 am

Additional response to bayardi

You need the 750ms delay placed directly after the ds.convert_temp().

Best regards

Post Reply