Trouble compiling for ESP8266 - dallas vs one_wire

Could someone tell me what’s wrong with this fragment of code?

dallas:
  - pin: D2
    update_interval: 60s
    
sensor:
  - platform: dallas
    index: 0
    #address: 0x1c0000031edd2a28
    name: "HW Temperature"
    id: "HWTemperature"

The initial error message says dallas should be one_wire but then I get into a spiral of error messages that never seem to resolve the issue. ChatGPT and Gemini have both failed to sort it out. Is there a human out there that can help? Many thanks!

Well no surprises there. The component was changed after they were trained. Rather than relying on outdated bulshit LLMs try reading the official documentation, It has a very clear examples.

2 Likes

I’m wondering if he needs to add the One wire config to esphome as it’s getting confused ?

See this post

Actually that hierarchy looks correct

one_wire → dallas

If you’re building this through arduino it makes sense

#include <OneWire.h> 
#include <DallasTemperature.h>

No they are just using outdated config. It is now:

one_wire:
  - platform: gpio
    pin: GPIOXX

sensor:
  - platform: dallas_temp  ### <---- COMPARE TO WHAT THEY HAVE.
    address: 0x1234567812345628
    name: temperature
    update_interval: 120s
1 Like

Ahhh ic … Thanks !

Thank you for your help.

This is what I’ve done:


one_wire:
  - platform: gpio
    pin: D2

sensor:
  - platform: dallas_temp
    #index: 0
    address: 0x1c0000031edd2a28
    name: "HW Temperature"
    id: "HWTemperature"
    update_interval: 60s

And this is what I’m getting:

[20:38:55][W][component:170]: Component dallas_temp.sensor cleared Warning flag
[20:38:56][W][dallas.temp.sensor:139]: 'HW Temperature' - Scratch pad checksum invalid!
[20:38:56][W][component:157]: Component dallas_temp.sensor set Warning flag: scratch pad checksum invalid
[20:38:56][D][sensor:093]: 'HW Temperature': Sending state nan °C with 1 decimals of accuracy
[20:39:16][I][safe_mode:041]: Boot seems successful; resetting boot loop counter
[20:39:55][W][component:170]: Component dallas_temp.sensor cleared Warning flag
[20:39:56][W][dallas.temp.sensor:139]: 'HW Temperature' - Scratch pad checksum invalid!
[20:39:56][W][component:157]: Component dallas_temp.sensor set Warning flag: scratch pad checksum invalid
[20:39:56][D][sensor:093]: 'HW Temperature': Sending state nan °C with 1 decimals of accuracy
[20:40:55][W][component:170]: Component dallas_temp.sensor cleared Warning flag
[20:40:56][W][dallas.temp.sensor:139]: 'HW Temperature' - Scratch pad checksum invalid!
[20:40:56][W][component:157]: Component dallas_temp.sensor set Warning flag: scratch pad checksum invalid
[20:40:56][D][sensor:093]: 'HW Temperature': Sending state nan °C with 1 decimals of accuracy
[20:41:33][D][switch:016]: 'HW RELAY' Turning OFF.
[20:41:55][W][component:170]: Component dallas_temp.sensor cleared Warning flag
[20:41:56][W][dallas.temp.sensor:139]: 'HW Temperature' - Scratch pad checksum invalid!
[20:41:56][W][component:157]: Component dallas_temp.sensor set Warning flag: scratch pad checksum invalid
[20:41:56][D][sensor:093]: 'HW Temperature': Sending state nan °C with 1 decimals of accuracy
[20:42:55][W][component:170]: Component dallas_temp.sensor cleared Warning flag
[20:42:56][W][dallas.temp.sensor:139]: 'HW Temperature' - Scratch pad checksum invalid!
[20:42:56][W][component:157]: Component dallas_temp.sensor set Warning flag: scratch pad checksum invalid
[20:42:56][D][sensor:093]: 'HW Temperature': Sending state nan °C with 1 decimals of accuracy

How is your wiring and connections? Soldered wires and 4k7 pullup to 3.3V?

It was all working fine with the old code in post 1, so I think the hardware is OK.

Likely yes.
But I’m not familiar with the old code and if it verified checksum.

Try to remove the " after the ID:

Further up in the log is the 1wire bus set up correctly and does it discover your sensor?

Please share that part of the log.

How about clearing your build files?

Very long thread indicating others see something similar.

I do not currently have any DS18B20 sensors on esphome, but I did have one last year and it worked fine. I mainly use Tasmota with ESP8266 and they all generally work fine and have for as much as more than a decade.

Sure. Here is the whole log:

INFO ESPHome 2024.11.3
INFO Reading configuration /config/esphome/esp8266_hw.yaml...
INFO Generating C++ source...
INFO Compiling app...
Processing esp8266-hw (board: d1_mini; framework: arduino; platform: platformio/[email protected])
--------------------------------------------------------------------------------
HARDWARE: ESP8266 80MHz, 80KB RAM, 4MB Flash
Dependency Graph
|-- ESPAsyncTCP-esphome @ 2.0.0
|-- ESPAsyncWebServer-esphome @ 3.2.2
|-- DNSServer @ 1.1.1
|-- ESP8266WiFi @ 1.0
|-- ESP8266mDNS @ 1.2
|-- noise-c @ 0.1.6
RAM:   [====      ]  42.3% (used 34680 bytes from 81920 bytes)
Flash: [=====     ]  48.2% (used 503725 bytes from 1044464 bytes)
========================= [SUCCESS] Took 7.03 seconds =========================
INFO Successfully compiled program.
INFO Connecting to 192.168.20.162 port 8266...
INFO Connected to 192.168.20.162
INFO Uploading /data/build/esp8266-hw/.pioenvs/esp8266-hw/firmware.bin (507872 bytes)
INFO Compressed to 355255 bytes
Uploading: [============================================================] 100% Done...


INFO Upload took 5.60 seconds, waiting for result...
INFO OTA successful
INFO Successfully uploaded program.
INFO Starting log output from 192.168.20.162 using esphome API
INFO Successfully connected to esp8266-hw @ 192.168.20.162 in 15.364s
INFO Successful handshake with esp8266-hw @ 192.168.20.162 in 2.830s
[18:26:00][I][app:100]: ESPHome version 2024.11.3 compiled on Apr 27 2025, 20:36:28
[18:26:00][C][wifi:600]: WiFi:
[18:26:00][C][wifi:428]:   Local MAC: 84:CC:A8:B4:0F:AC
[18:26:00][C][wifi:433]:   SSID: [redacted]
[18:26:00][C][wifi:436]:   IP Address: 192.168.20.162
[18:26:00][C][wifi:439]:   BSSID: [redacted]
[18:26:00][C][wifi:441]:   Hostname: 'esp8266-hw'
[18:26:00][C][wifi:443]:   Signal strength: -68 dB ▂▄▆█
[18:26:00][C][wifi:447]:   Channel: 2
[18:26:00][C][wifi:448]:   Subnet: 255.255.255.0
[18:26:00][C][wifi:449]:   Gateway: 192.168.20.1
[18:26:00][C][wifi:450]:   DNS1: 192.168.50.50
[18:26:00][C][wifi:451]:   DNS2: 0.0.0.0
[18:26:00][C][logger:185]: Logger:
[18:26:00][C][logger:186]:   Level: DEBUG
[18:26:00][C][logger:188]:   Log Baud Rate: 115200
[18:26:00][C][logger:189]:   Hardware UART: UART0
[18:26:01][C][gpio.one_wire:020]: GPIO 1-wire bus:
[18:26:01][C][gpio.one_wire:021]:   Pin: GPIO4
[18:26:01][C][gpio.one_wire:080]:   Found devices:
[18:26:01][C][gpio.one_wire:082]:     0x303c01d6072e4928 (DS18B20)
[18:26:01][C][switch.gpio:068]: GPIO Switch 'HW LED'
[18:26:01][C][switch.gpio:076]:   Inverted: YES
[18:26:01][C][switch.gpio:090]:   Restore Mode: always OFF
[18:26:01][C][switch.gpio:031]:   Pin: GPIO2
[18:26:01][C][switch.gpio:068]: GPIO Switch 'HW RELAY'
[18:26:01][C][switch.gpio:090]:   Restore Mode: always OFF
[18:26:01][C][switch.gpio:031]:   Pin: GPIO13
[18:26:01][C][dallas.temp.sensor:029]: Dallas Temperature Sensor:
[18:26:01][C][dallas.temp.sensor:034]:   Address: 0x1c0000031edd2a28 (DS18B20)
[18:26:01][C][dallas.temp.sensor:035]:   Resolution: 12 bits
[18:26:01][C][dallas.temp.sensor:036]:   Update Interval: 60.0s
[18:26:01][C][captive_portal:089]: Captive Portal:
[18:26:01][C][mdns:116]: mDNS:
[18:26:01][C][mdns:117]:   Hostname: esp8266-hw
[18:26:01][C][esphome.ota:073]: Over-The-Air updates:
[18:26:01][C][esphome.ota:074]:   Address: esp8266-hw.local:8266
[18:26:01][C][esphome.ota:075]:   Version: 2
[18:26:01][C][esphome.ota:078]:   Password configured
[18:26:01][C][safe_mode:018]: Safe Mode:
[18:26:01][C][safe_mode:019]:   Boot considered successful after 60 seconds
[18:26:01][C][safe_mode:021]:   Invoke after 10 boot attempts
[18:26:01][C][safe_mode:022]:   Remain in safe mode for 300 seconds
[18:26:01][C][api:140]: API Server:
[18:26:01][C][api:141]:   Address: esp8266-hw.local:6053
[18:26:01][C][api:143]:   Using noise encryption: YES
[18:26:01][D][api:103]: Accepted 192.168.20.81
[18:26:02][W][component:237]: Component api took a long time for an operation (286 ms).
[18:26:02][W][component:238]: Components should block for at most 30 ms.
[18:26:04][D][api.connection:1446]: Home Assistant 2025.4.4 (192.168.20.81): Connected successfully
[18:26:44][W][component:170]: Component dallas_temp.sensor cleared Warning flag
[18:26:45][W][dallas.temp.sensor:139]: 'HW Temperature' - Scratch pad checksum invalid!
[18:26:45][W][component:157]: Component dallas_temp.sensor set Warning flag: scratch pad checksum invalid
[18:26:45][D][sensor:093]: 'HW Temperature': Sending state nan °C with 1 decimals of accuracy
[18:26:50][I][safe_mode:041]: Boot seems successful; resetting boot loop counter
[18:27:44][W][component:170]: Component dallas_temp.sensor cleared Warning flag
[18:27:45][W][dallas.temp.sensor:139]: 'HW Temperature' - Scratch pad checksum invalid!
[18:27:45][W][component:157]: Component dallas_temp.sensor set Warning flag: scratch pad checksum invalid
[18:27:45][D][sensor:093]: 'HW Temperature': Sending state nan °C with 1 decimals of accuracy

Hello again. It turns out I’d made a mistake with the address. The address in the log didn’t match the address in the code. I’ve corrected that now and it seems to be working fine.

Thank you for the earlier help, which was also essential to fixing the problem.

1 Like