My Dallas DS18B20 sensor shows correct raw temperatures in logs (e.g., 19.6°C), but ESPHome reports a different value to Home Assistant (like 30.4°C). I suspect a leftover conversion or filter, but I’ve rebuilt it several times. There was an early version with unit_of_measurement: set as F° that was changed. Reports fine with an offset but not when calibrate_linear is applied instead.
- ESP8266 board (D1 Mini)
- Dallas DS18B20 sensor on GPIO2
- 4.7KΩ Resistor
- ESPHome version: [2024.12.4]
- Home Assistant version: [2025.1.4]
Setup Details:
What’s happening:
- Raw log shows correct temp:
Got Temperature=19.6°C
- ESPHome sends wrong state:
Sending state 30.41944 °C
- Home Assistant reports this inflated value as around 86°F+
What I’ve tried:
- Removed
lambda
functions, filters, and calibrations - Cleaned build files (
esphome clean
) - Erased flash (
esptool.py erase_flash
) and reflashed - Tried minimal config with no filters
- Tested multiple
calibrate_linear
andoffset
setups - Added state_class: “measurement”
Logs
[23:58:30][D][dallas.temp.sensor:054]: 'Water Temperature': Got Temperature=19.6°C
[23:58:30][D][sensor:093]: 'Water Temperature': Sending state 30.41944 °C with 1 decimals of accuracy
YAML
esphome:
name: fish-tank-temp
friendly_name: Fish Tank Temp
esp8266:
board: esp01_1m
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
- platform: esphome
password: ""
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Fish-Tank-Temp AP"
password: !secret sexy_ap_password
captive_portal:
button:
- platform: restart
name: "Fish Tank Temp Sensor Restart"
# One witre configuration
one_wire:
- platform: gpio
pin: GPIO2
sensor:
- platform: dallas_temp
address: 0xe3000000365c4c28
name: "Water Temperature"
update_interval: 5s
unit_of_measurement: "°C"
device_class: "temperature"
state_class: "measurement"
filters:
- calibrate_linear:
datapoints:
- 5.0 -> 0.0 # Ice water reading -> 32°F / 0°C
- 14.0 -> 18.8 # Room temp reading -> 65°F / 18.3°C
#- offset: -5.0 # Original Offset / Subtracting 8.1°C from the sensor reading
#- sliding_window_moving_average: # Removed for Troubleshooting
# window_size: 5
# send_every: 1
# send_first_at: 1