Can't read DS18B20

I’m sure its something stupid, but I can’t get a DS18B20 to read a temp. It always displays NAN.

My yaml info

dallas:
  - pin: 21

sensor:
  - platform: dallas
    address: 0xa70214811610ff28
    name: “Spa Temperature"

On boot, my esp32 finds it
[

20:42:52][D][dallas.sensor:082]:   Found sensors:
[20:42:52][D][dallas.sensor:084]:     0xa70214811610ff28
[20:42:52][C][dallas.sensor:089]:   Device '“Spa Temperature"'
[20:42:52][C][dallas.sensor:089]:     Device Class: 'temperature'
[20:42:52][C][dallas.sensor:089]:     State Class: 'measurement'
[20:42:52][C][dallas.sensor:089]:     Unit of Measurement: '°C'
[20:42:52][C][dallas.sensor:089]:     Accuracy Decimals: 1
[20:42:52][C][dallas.sensor:097]:     Address: 0xa70214811610ff28
[20:42:52][C][dallas.sensor:098]:     Resolution: 12
[20:42:52][C][captive_portal:088]: Captive Portal:

But when its running, I get this error message over and over

[20:54:42][W][dallas.sensor:131]: '“Spa Temperature"' - Resetting bus for read failed!
[20:54:42][D][sensor:125]: '“Spa Temperature"': Sending state nan °C with 1 decimals of accuracy

I tried same code on a ESP8266 with same result.
My existing setup which runs on ESPEasy reads the temps with no problem.

Any advice?

Thanks
Randy

Do you have any other sensors configured? From memory Dallas one-wire used to clash with some config settings, but I thought that had been fixed.

Maybe post your full redacted YAML.

Here are all the sensor definitions. Rest of the yaml is just the general, wifi and mqtt setup

Not doing much.

switch:
  - platform: gpio
    name: "heaterspa"
    pin: 19
    restore_mode: ALWAYS_OFF
    inverted: True

  - platform: gpio
    name: "heaterpool"
    pin: 23
    restore_mode: ALWAYS_OFF
    inverted: True

  - platform: gpio
    name: "spapump"
    pin: 18
    restore_mode: ALWAYS_OFF
    inverted: True

binary_sensor:
  - platform: gpio
    pin:
      number: 22
      mode: INPUT_PULLUP
#      inverted: True
    name: “Spa Air Switch"
#    device_class: window
    filters:
      - delayed_on: 40ms
      - delayed_off: 40ms

dallas:
  - pin: 21

sensor:
  - platform: dallas
    address: 0xa70214811610ff28
    name: “Spa Temperature"

Sorry - nothing obvious jumping out. Have you installed it with an external pull-up as recommended?

image

I’m sure I have a resistor there. Its late and dark here, can double check tomorrow after work.

Randy

You have something weird in the title
quotation marks

name: “Spa Temperature"
name: “Spa Air Switch"

correctly:

name: "Spa Temperature"

Was hoping that was it, but it didn’t make a difference. Same result

Everything looks fine. Check wiring and soldering. Try another pin esp32. Check the length of the wire (long can be a problem). Alternatively, try another Dallas if you have one. I can’t think of anything else.

Thanks, I was thinking along those lines.

I have another dallas. I’m going to throw together another setup later today after work or tomorrow. This one is installed in the backyard, it will be easier to experiment in my “lab”.
Will post update after I try with a 2nd setup.

Randy

So I tried a DS18B20 in my “lab”, and that worked fine.

Moved back and same problem. So I reworked the data line/pullup connection, still no joy
Then I resoldered the VCC and Gnd connection to the DS, and finally it worked.
The VCC and gnd connections did look suspect. Just didn’t make sense since its been working with espeasy for many years.

I’ll probably change it back to an ESP8266 now. Tried that first, didn’t work so I tried the esp32.

One more question. How would I convert from C to F at with ESPHome? I can do it with templates in Home Assistant, pretty sure the method is similar with ESPHome.

Randy

sensor:
  - platform: dallas
    address: 0xa70214811610ff28
    name: "Spa Temperature"
    filters:
      - lambda: return x * (9.0/5.0) + 32.0;
    unit_of_measurement: "°F"
1 Like

Worked great, thanks

Hello,

How did you solved the issue ?
You still use ESP32 ?

I get same error ! Thank you !

I’m using ESP32 with no problems.

I added the lamda filter to do the C to F conversion

Hey how could I make this Lambda post in deg C?

Thanks!

deg C is the default I believe - just set the unit of measurement to “°C”

1 Like