Dallas DS18B20 on Pico not working "Resetting bus for read failed"

Hi!

As you can already read in the title, I’ve got problems reading the Dallas DS18B20 on my Pico W.

It started at around 6pm last evening when I started experimenting with the SSD1306 connected to the same Pico. After that, the DS18B20 lost connection over and over (reporting 85°C) but recovering and reporting the correct temperature. Then, I’ve noticed it this morning that it doesn’t work properly anymore. I’ve tried filtering the 85°C out, but then it started to report inf °C. Then, I’ve added the resistor, tested it successfully with my esp8266 and changed the pin the DS18B20 is connected to twice.

Log:

<!-- snip -->
[16:25:48][D][dallas.sensor:082]:   Found sensors:
[16:25:48][D][dallas.sensor:084]:     0x2707226138939b28
<!-- snip -->
[16:30:29][W][dallas.sensor:131]: 'Temperatur' - Resetting bus for read failed!
[16:30:29][D][sensor:109]: 'Temperatur': Sending state inf °C with 1 decimals of accuracy
<!-- snip -->

What I’ve tried

  • I used the sensor with an esp8266 and it worked fine.
  • I tried 2 other pins, same result
  • Adding the 4.7kOhm resistor (Worked for a month without it)
  • Unplugging the OLED

Actions that could have lead to this behavior:

Upgrading to Esphome 2023.4.2

I don’t really know when that was.

Adding the following code

i2c: 
  - id: bus_a
    sda: GPIO20
    scl: GPIO21
    scan: true
  - id: front
    sda: GPIO6
    scl: GPIO7
  
  display:
   - platform: ssd1306_i2c
     i2c_id: front
     model: "SSD1306 128x64"
     rotation: "90°"
     lambda: |-
       it.printf(0, 0, id(roboto), "%.1f°C", id(temp).state);
       it.printf(0, 15, id(roboto), "%.0fPPM", id(aquarium_tds).state);

 font:
   - file: "gfonts://Roboto"
     id: "roboto"
     size: 15

(This doesn’t seem to br formatted correctly but it works)

Config

<!-- snip -->
dallas:
  - pin: GPIO20
    update_interval: 10s

sensor:
  # Temperatur
  - platform: dallas
    address: 0x2707226138939b28
    name: "Temperatur"
    id: "temp"

<!-- Config below was added as a part of troubleshooting and should replace the commented out section below that -->
  - platform: adc
    pin: GPIO28
    name: "Aquarium tds raw voltage"
    id: tds_raw_v
    update_interval: 10s
    unit_of_measurement: "V"
    icon: "mdi:water-percent"
    internal: true

# Temperature Compensated Voltage  
  - platform: template
    name: "TDS TCV"
    id: tds_tcv
    unit_of_measurement: 'v'
    accuracy_decimals: 3
    lambda: 'return ((id(tds_raw_v).state) / (1 + (0.02 * ((id(temp).state) - 25.0))));'
    update_interval: 10s
    internal: true
  
# Temperature Compensated TDS
  - platform: template
    name: "Aquarium TDS"
    id: aquarium_tds
    icon: "hass:water-opacity"
    unit_of_measurement: 'PPM'
    accuracy_decimals: 0    
    update_interval: 10s
    lambda: return (133.42*(id(tds_tcv).state)*(id(tds_tcv).state)*(id(tds_tcv).state) - 255.86*(id(tds_tcv).state)*(id(tds_tcv).state) + 857.39*(id(tds_tcv).state))*0.5;

  <!-- The block below was commented out as a part of the troubleshooting process -->
  # - platform: adc # Hier wird die rohe Spannung des TDS Sensors gemessen
  #   pin: GPIO28
  #   name: "TDS raw"
  #   id: tds_raw_v
  #   update_interval: 10s
  #   unit_of_measurement: "V"
  #   icon: "mdi:water-percent"
  #   internal: true
  #   filters:
  #     - filter_out: nan # Messfehler werden gefiltert
  # - platform: template # Hier wird die Spannung mit der Temperatur verrechnet
  #   name: "TDS TCV"
  #   id: tds_tcv
  #   unit_of_measurement: 'V'
  #   accuracy_decimals: 3
  #   lambda: 'return ((id(tds_raw_v).state) / (1 + (0.02 * ((id(temp).state) - 25.0))));'
  #   update_interval: 10s
  #   filters:
  #     - filter_out: nan # Messfehler werden gefiltert
  #   internal: true
  # - platform: template
  #   name: "Aquarium TDS"
  #   id: aquarium_tds
  #   icon: "hass:water-opacity"
  #   unit_of_measurement: 'PPM'
  #   accuracy_decimals: 0    
  #   update_interval: 10s
  #   filters:
  #     - filter_out: nan # Messfehler werden gefiltert
  #     - median: # von 5 gemessenen Werten wird der Durchschnitt gebildet
  #         window_size: 5
  #         send_every: 5
  #         send_first_at: 5
  #   lambda: 'return (133.42*(id(tds_tcv).state)*(id(tds_tcv).state)*(id(tds_tcv).state) - 255.86*(id(tds_tcv).state)*(id(tds_tcv).state) + 857.39*(id(tds_tcv).state))*0.5;' # Verrechnung der Werte

  - platform: hx711
    name: "Weight Measured"
    dout_pin: GPIO14
    clk_pin: GPIO15
    gain: 128
    update_interval: 10s
    filters:
      - calibrate_linear:
          - 373194 -> 0
          - 346167 -> 1
          - 292225 -> 3
          - 278793 -> 3.5
    unit_of_measurement: kg

<!-- snip -->

I’ve also got i²C configured, a pwm output which I didn’t include in the config above.

Looking forward to your help since I couldn’t find anyone who had the same issue where the sensor gets detected but reports inf °C.

Fixed it, the 3.3v connection was faulty.