AHT20 with ESP32 and ESPHome: Wiring, Calibration and Home Assistant

Connect an AHT20 temperature and humidity sensor to ESP32 and ESPHome. Covers 0x38 wiring, AHT20 variant setup, calibration offsets, filtering, self-heating, placement, condensation and Home Assistant.

The AHT20 is one of the cheapest temperature-and-humidity sensors that is still good enough for serious ESP32 and Home Assistant projects. It uses standard I²C, has a fixed address of 0x38, offers typical accuracy around ±0.3°C and ±2% RH, and is directly supported by ESPHome.

The slightly confusing part is ESPHome’s component name: AHT20 is configured through the aht10 platform, with variant: AHT20. Once that is set correctly, the sensor is straightforward.

This guide covers the practical details that matter after wiring: correct ESPHome YAML, I²C troubleshooting, calibration offsets, filtering, thermal placement, measurement interval, high-humidity behaviour and how to decide whether an apparent sensor error is actually caused by the enclosure or ESP32 heating.

AHT20 Specifications

FeatureAHT20
MeasurementsTemperature + relative humidity
InterfaceI²C
I²C address0x38, fixed
Typical temperature accuracy±0.3°C
Typical humidity accuracy±2% RH
Temperature range-40 to 85°C
Humidity range0–100% RH extended range
Normal long-term humidity range0–80% RH
Humidity response time~8 s to 63%
Temperature response5–30 s depending on thermal environment
Supply voltage, bare sensor2.0–5.5 V
Typical measurement currentVery low; tens of µA class
ESPHome supportaht10 platform with variant: AHT20

The important accuracy caveat is that the headline values are specified under controlled factory conditions, around 25°C, and for non-condensing operation. The sensor can operate outside the 0–80% RH normal range, but prolonged exposure above that range can cause temporary humidity drift.

AHT20 Wiring to ESP32

On a classic ESP32 DevKit:

AHT20 breakoutESP32
VCC / VIN3.3 V
GNDGND
SDAGPIO21
SCLGPIO22

Although many AHT20 breakout boards accept 5 V, using 3.3 V with an ESP32 keeps the I²C logic safely in the ESP32’s voltage domain.

Breakout-board specifications matter here. A bare AHT20 sensor may tolerate a wider supply range, while a particular module may contain regulators, LEDs and I²C pull-ups wired differently. When in doubt, use 3.3 V.

The I²C Address Is Fixed at 0x38

AHT20 responds at:

0x38

Unlike sensors such as BME280, the address cannot normally be changed with a solder jumper.

This matters when you want two AHT20 sensors on the same I²C bus. Both answer at 0x38, so you need an I²C multiplexer such as TCA9548A or an address translator rather than simply changing one sensor’s address.

That fits naturally with our upcoming TCA9548A I²C Multiplexer with ESP32 guide later in this batch.

ESPHome AHT20 Configuration

Current ESPHome uses the aht10 platform for AHT10, AHT20 and AHT30 devices.

i2c:
  sda: GPIO21
  scl: GPIO22
  scan: true

sensor:
  - platform: aht10
    variant: AHT20

    temperature:
      name: "Room Temperature"
      id: room_temperature

    humidity:
      name: "Room Humidity"
      id: room_humidity

    update_interval: 60s

The explicit line:

variant: AHT20

is worth keeping even though the component supports several related sensors. It removes ambiguity and makes the YAML self-documenting.

Why Is the ESPHome Platform Called aht10?

ESPHome originally supported the AHT10 family through this component and later extended it to AHT20/AHT30.

Current ESPHome documentation lists:

variant: AHT10
variant: AHT20   # also used for AHT30

It even notes that some sensors physically marked AHT10 may actually require the AHT20 protocol variant. If a device appears at 0x38 but ESPHome fails to fetch data, trying variant: AHT20 is a valid troubleshooting step.

ESPHome Verbose Log Warning

ESPHome documents one unusual behaviour: when humidity is enabled, verbose logging may show:

Components should block for at most 20-30ms in loop().

ESPHome states that this is caused by the sensor’s technical measurement behaviour and cannot be avoided by the component.

If the sensor is otherwise returning correct values, this warning alone does not mean the I²C bus is failing.

Use a Sensible Update Interval

AHT20 is not a sensor that benefits from being read 100 times per second.

The manufacturer’s application guidance warns that very frequent measurements cause self-heating and can affect accuracy. It recommends limiting active measurement time and suggests a measurement interval of roughly two seconds or longer if temperature rise is to remain small.

For Home Assistant:

30s → responsive room sensor
60s → excellent general default
5min → enough for slow climate monitoring

ESPHome’s default 60-second polling interval is therefore already very conservative and minimises sensor self-heating.

Temperature Placement Matters More Than Calibration

If your AHT20 reads 1–2°C high, do not immediately add a software offset.

First check where it is mounted.

The manufacturer’s own layout guidance recommends isolating the sensor from heat-producing electronics and providing good airflow. An ESP32 Wi-Fi radio, regulator and USB interface can easily warm the local PCB and enclosure.

A typical bad layout is:

ESP32 module
regulator
AHT20
all inside sealed plastic box

The temperature rises above room air and the calculated relative humidity often appears lower as a result.

Better Sensor Placement

  • Place the AHT20 near the edge of the PCB.
  • Keep it away from the ESP32 module and voltage regulator.
  • Use ventilation slots near the sensor.
  • Avoid direct sunlight.
  • Avoid mounting directly above a warm power supply.
  • Do not place foam, adhesive or volatile plastics immediately around the sensing element.

A physical layout improvement is normally preferable to compensating for permanent self-heating in software.

AHT20 Calibration: Start with a Reference

AHT20 comes factory-calibrated. Do not calibrate it simply because two cheap sensors disagree by 0.5°C or 3% RH.

Use a known reference and compare under controlled conditions:

  1. Place the AHT20 and reference sensor close together.
  2. Keep them out of direct sun and drafts.
  3. Allow at least 20–30 minutes for temperature equalisation.
  4. Compare several readings, not one instant value.
  5. Correct placement errors before adding software calibration.

Simple Temperature Offset in ESPHome

If a stable reference shows that your installed sensor is consistently +0.4°C high after thermal-placement issues have been resolved:

temperature:
  name: "Room Temperature"
  filters:
    - offset: -0.4

This is appropriate for a genuine consistent bias.

It is not appropriate when the error changes from +0.3°C when idle to +1.5°C while Wi-Fi is busy. That is a thermal-design problem rather than a calibration problem.

Humidity Offset

The same ESPHome filter can apply a small verified RH correction:

humidity:
  name: "Room Humidity"
  filters:
    - offset: 2.0
    - clamp:
        min_value: 0
        max_value: 100

Again, only do this after confirming the offset against a trustworthy reference under stable temperature conditions.

Humidity comparisons are meaningless when the sensors themselves are at different temperatures because relative humidity depends strongly on temperature.

Two-Point Humidity Calibration

If a sensor shows a genuine slope error rather than a fixed offset, a two-point calibration is better than one offset.

For example, suppose a trusted reference gives:

AHT20 reads 35% → reference 37%
AHT20 reads 75% → reference 73%

You can use:

humidity:
  name: "Room Humidity"
  filters:
    - calibrate_linear:
        - 35.0 -> 37.0
        - 75.0 -> 73.0
    - clamp:
        min_value: 0
        max_value: 100

Do not invent calibration points from expected room humidity. Use actual reference measurements.

Filtering Is Usually Not Necessary

AHT20 is a digital I²C sensor, so it does not suffer the ADC noise of a cheap analogue probe.

For most installations, publish its readings directly.

If the display is visually noisy, a small moving average can improve presentation:

temperature:
  name: "Room Temperature"
  filters:
    - sliding_window_moving_average:
        window_size: 3
        send_every: 1

With a 60-second update interval, this creates approximately a three-minute rolling average.

Do not smooth so aggressively that real ventilation or heating changes disappear.

High Humidity and Condensation

The AHT20 can report across an extended 0–100% RH range, but the manufacturer defines the normal operating range more conservatively and warns about prolonged exposure above about 80% RH.

Extended high humidity can cause temporary drift. Condensing water is more problematic still: headline accuracy is specified for non-condensing conditions.

This matters in:

  • Bathrooms.
  • Greenhouses.
  • Outdoor enclosures.
  • Refrigeration.
  • HVAC ducts.

If condensation is expected routinely, use an enclosure and sensor architecture designed for that environment rather than simply exposing a cheap breakout to water droplets.

Chemical Vapours Can Shift Humidity Readings

The AHT20 documentation specifically warns about prolonged exposure to volatile solvents, adhesives, adhesive tapes and some packaging materials.

This can matter in freshly built 3D-printed or glued enclosures. A sensor installed immediately beside curing adhesive can drift and appear faulty even though the electronics are working normally.

Allow enclosures and adhesives to outgas before final calibration.

Recovery After Extreme Humidity or Chemical Exposure

Aosong documents recovery procedures for sensors that have drifted after extreme environmental or chemical exposure, involving controlled drying and rehydration conditions.

For a normal hobby module, the practical first step is simpler:

  • Remove it from the extreme environment.
  • Allow it to stabilise in normal room conditions.
  • Compare it against a reference after sufficient recovery time.
  • Replace the inexpensive module if drift remains unacceptable.

Do not place an assembled hobby breakout in an oven simply because the bare-sensor datasheet describes a manufacturing recovery procedure; the rest of the module may not tolerate those conditions.

Multiple AHT20 Sensors on One ESP32

Because every normal AHT20 uses address 0x38, two sensors cannot share one ordinary I²C bus directly.

Options are:

  • Use a TCA9548A I²C multiplexer.
  • Use an I²C address translator.
  • Use separate I²C buses on ESP32 variants that support/configure them conveniently.
  • Choose sensors with selectable addresses instead.

If you are building a multi-room wired sensor hub, TCA9548A is usually the cleanest solution.

AHT20 vs DHT22

FeatureAHT20DHT22
InterfaceI²CSingle-wire proprietary timing
Typical humidity accuracy~±2% RHGenerally poorer class
Temperature accuracy~±0.3°CTypically around ±0.5°C class
ESP32 integrationVery easyEasy but timing-dependent
Bus sharingYes, but fixed addressSeparate data pin per sensor
Recommended new projectAHT20Only when already available/required

AHT20 is usually the better inexpensive choice for a new ESP32 project.

AHT20 vs SHT40

Sensirion’s SHT4x family is the stronger option when humidity performance and long-term quality matter more than the lowest possible cost.

AHT20 remains attractive when you want:

  • Very low cost.
  • Good-enough room climate accuracy.
  • Simple I²C wiring.
  • Direct ESPHome support.

See our Best Temperature & Humidity Sensor for ESP32 comparison for the wider decision.

AHT20 vs BME280

AHT20 measures only temperature and humidity. BME280 adds barometric pressure.

For a simple indoor room sensor, AHT20 can be cheaper and perfectly adequate. For a weather station or a device where pressure is useful, BME280 gives more information from one I²C address.

See our BMP280 vs BME280 comparison.

Home Assistant Configuration

Nothing special is required on the Home Assistant side when the ESPHome Native API is used. The temperature and humidity entities are discovered automatically.

A complete node can look like:

esphome:
  name: bedroom-climate
  friendly_name: Bedroom Climate

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

logger:

api:
  encryption:
    key: !secret api_encryption_key

ota:
  - platform: esphome
    password: !secret ota_password

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

i2c:
  sda: GPIO21
  scl: GPIO22
  scan: true

sensor:
  - platform: aht10
    variant: AHT20

    temperature:
      name: "Temperature"
      filters:
        - offset: 0.0

    humidity:
      name: "Humidity"
      filters:
        - clamp:
            min_value: 0
            max_value: 100

    update_interval: 60s

Leave the temperature offset at zero unless you have measured a genuine bias.

Useful Home Assistant Automations

MeasurementPossible use
Humidity >70%Bathroom ventilation notification/control
Humidity rising quicklyDetect shower/steam event
Temperature too highClimate/awning/shutter automation
Very low humidityHumidifier reminder
Temperature + humidityCalculate dew point / comfort indicators

For bathroom extraction, avoid relying on one absolute RH threshold in every season. A rise-rate or comparison against another indoor sensor can be more robust.

Common Problems

SymptomLikely cause / first check
No device in I²C scanCheck VCC/GND/SDA/SCL and 0x38
0x38 detected but no measurementsSet variant: AHT20
Temperature 1–2°C too highESP32/regulator/enclosure heating
Humidity consistently too lowSensor is warmer than ambient; fix temperature bias first
Humidity drifts after bathroom/greenhouse useProlonged high RH/condensation
Readings change after gluing enclosureVolatile adhesive/solvent exposure
Cannot add second AHT20Both use fixed 0x38 address
Verbose ESPHome blocking warningDocumented AHT humidity-read behaviour
Values seem noisyCheck placement first; then use light averaging
Device goes unavailable, sensor values disappearLikely ESPHome/Wi-Fi problem rather than AHT20

Recommended Setup

For a normal ESP32 Home Assistant room sensor:

  • Power the breakout from 3.3 V.
  • Use the standard ESP32 I²C pins or clean alternative GPIOs.
  • Enable I²C scanning during commissioning.
  • Set variant: AHT20.
  • Use a 30–60 second update interval.
  • Mount the sensor away from ESP32 heat.
  • Do not add calibration offsets until compared with a trusted reference.
  • Avoid prolonged condensation and volatile adhesives around the sensor.

With those basics correct, AHT20 is an excellent low-cost sensor for bedrooms, living spaces, utility rooms and general Home Assistant climate monitoring.

Related Temperature and Humidity Guides

Official and Reference Resources

Share your love