SHT45 Temperature and Humidity Sensor with ESPHome and MQTT for Home Assistant

The Sensirion SHT45 is one of the most accurate, stable sensors you can use for temperature and humidity monitoring. It is a true upgrade over common “good enough” sensors, especially in spaces where small changes matter such as a humidor, curing chamber, greenhouse, wine cabinet, bathroom, or any room where you want precise control.

A major advantage of the SHT4x family is the built-in heater. The heater can be used to dry the sensing element after condensation or persistent high humidity conditions, which helps keep readings reliable over time.

This guide shows how to wire an SHT45 to an ESP32, flash it with ESPHome, publish values over MQTT, and optionally expose the heater as a button in Home Assistant.

Hardware and wiring

What you need

ESP32 development board (ESP32 DevKitC v4, ESP32-S3, ESP32-C3 all work)
Sensirion SHT45 breakout module
Jumper wires
An enclosure that allows airflow (do not seal the sensor airtight)

Wiring uses I2C. Most ESP32 boards commonly use GPIO21 for SDA and GPIO22 for SCL, but you can change pins if you prefer.

SHT45 pin to ESP32 wiring

VCC or VIN to 3V3
GND to GND
SDA to GPIO21
SCL to GPIO22

Important note about power: The safe choice is always 3.3V. Even if some breakout boards claim 5V compatibility, using 3V3 avoids level issues and prevents accidents.

I2C address

Most SHT4x devices use address 0x44 by default. Some modules can use 0x45. ESPHome can scan the bus and tell you which address is present.

ESPHome configuration with MQTT

The YAML below is designed to be copy pasted into ESPHome. It does the following:

Connects to Wi Fi with a fallback hotspot
Enables OTA updates
Publishes sensor readings to MQTT under a clean topic prefix
Reads temperature and humidity from the SHT45
Exposes a heater control as a Home Assistant button (optional)

Filename example: sht45-room-sensor.yaml

esphome:
  name: sht45_room_sensor
  friendly_name: "SHT45 Room Sensor"

esp32:
  board: esp32dev
  framework:
    type: esp-idf

logger:

wifi:
  ssid: "YOUR_WIFI_SSID"
  password: "YOUR_WIFI_PASSWORD"
  ap:
    ssid: "SHT45-Fallback"
    password: "change_this_password"

captive_portal:

ota:
  - platform: esphome

api:
  reboot_timeout: 0s

mqtt:
  broker: 192.168.1.100
  username: "mqtt_user"
  password: "mqtt_password"
  topic_prefix: "home/sht45_room_sensor"
  discovery: true

i2c:
  sda: 21
  scl: 22
  scan: true
  id: bus_a

sensor:
  - platform: sht4x
    i2c_id: bus_a
    address: 0x44
    update_interval: 15s

    temperature:
      name: "Temperature"
      id: sht45_temp
      unit_of_measurement: "°C"
      accuracy_decimals: 2
      filters:
        - offset: -0.5

    humidity:
      name: "Humidity"
      id: sht45_hum
      unit_of_measurement: "%"
      accuracy_decimals: 1

button:
  - platform: template
    name: "SHT45 Heater Dry Cycle"
    on_press:
      - sht4x.heater:
          id: sht45_temp
          power: "High"
          length: "Long"

How to adjust this YAML for your setup

board: Use esp32dev for ESP32 DevKitC v4 style boards. If you are using ESP32 C3 or S3, change the board type accordingly in ESPHome.
offset filter: Start with a small value like -0.5. If the sensor is close to the ESP32 and temperature reads high, increase the negative offset. A better fix is to physically separate the sensor from the ESP32 by a few centimeters using wires.
update_interval: 15 seconds is a good balance for room monitoring. If you only care about slow trends, 30 to 60 seconds reduces traffic.

MQTT topics and verification

If you enabled discovery: true, Home Assistant will typically create the entities automatically through MQTT discovery.

If you want to verify topics manually, use MQTT Explorer and look under:

home/sht45_room_sensor

You will see state topics for temperature and humidity. The exact topic names depend on how ESPHome formats entity names, so verifying once is recommended.

Home Assistant manual MQTT configuration

If you prefer manual sensors (or if discovery is disabled), add sensors in configuration.yaml using the state topics you confirmed in MQTT Explorer.

Example:

mqtt:
  sensor:
    - name: "Room Temperature"
      state_topic: "home/sht45_room_sensor/sensor/temperature/state"
      unit_of_measurement: "°C"
      device_class: temperature
      state_class: measurement

    - name: "Room Humidity"
      state_topic: "home/sht45_room_sensor/sensor/humidity/state"
      unit_of_measurement: "%"
      device_class: humidity
      state_class: measurement

  button:
    - name: "SHT45 Heater Dry Cycle"
      command_topic: "home/sht45_room_sensor/button/sht45_heater_dry_cycle/command"
      payload_press: "PRESS"

If your ESPHome sensor names differ, the topic strings will differ too. Use MQTT Explorer to copy the correct ones.

Using the heater correctly

The heater is not meant to be on constantly. It is used in short bursts to clear condensation or recover from saturation after long periods at very high humidity.

Good times to use it

Bathroom sensors that hit 100 percent humidity during showers
Greenhouse sensors exposed to condensation
Sensors that appear “stuck” at very high humidity

Safe usage pattern

Run the heater briefly once, then wait a few minutes and check whether humidity readings return to normal. Do not run repeated heater cycles back to back.

Optional automation idea

You can automate a heater burst if humidity stays above a threshold for a long time. This is an advanced pattern because you do not want to fight real humidity conditions in a greenhouse. For bathrooms it can be useful.

Example automation:

alias: "SHT45 Dry Sensor if Saturated"
trigger:
  - platform: numeric_state
    entity_id: sensor.room_humidity
    above: 95
    for: "00:20:00"
action:
  - service: button.press
    target:
      entity_id: button.sht45_heater_dry_cycle
mode: single

Troubleshooting

I2C device not found

Check SDA and SCL wiring
Confirm you used 3V3 and GND correctly
Look at ESPHome logs for the I2C scan results and confirm whether the sensor shows up at 0x44 or 0x45

Temperature reads too high

Move the SHT45 away from the ESP32 using wires
Add or adjust the offset filter
Avoid placing the sensor above voltage regulators or in direct sunlight

Humidity reads stuck at 100 percent

Likely condensation on the sensor
Run one heater dry cycle
Improve airflow in the enclosure

MQTT not updating

Confirm broker IP and credentials
Confirm Home Assistant MQTT integration is connected
Use MQTT Explorer to ensure messages are being published under your topic_prefix

Summary

With an SHT45 and ESPHome you get a high accuracy temperature and humidity sensor that is stable and fast. MQTT makes the data portable across your stack, and the heater gives you a practical way to recover from condensation and high humidity saturation. The configuration above works as a strong baseline, and you can scale it by adding more nodes around the house with consistent topic prefixes.

Share your love

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Leave a Reply

Your email address will not be published. Required fields are marked *