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
| Feature | AHT20 |
|---|---|
| Measurements | Temperature + relative humidity |
| Interface | I²C |
| I²C address | 0x38, fixed |
| Typical temperature accuracy | ±0.3°C |
| Typical humidity accuracy | ±2% RH |
| Temperature range | -40 to 85°C |
| Humidity range | 0–100% RH extended range |
| Normal long-term humidity range | 0–80% RH |
| Humidity response time | ~8 s to 63% |
| Temperature response | 5–30 s depending on thermal environment |
| Supply voltage, bare sensor | 2.0–5.5 V |
| Typical measurement current | Very low; tens of µA class |
| ESPHome support | aht10 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 breakout | ESP32 |
|---|---|
| VCC / VIN | 3.3 V |
| GND | GND |
| SDA | GPIO21 |
| SCL | GPIO22 |
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:
- Place the AHT20 and reference sensor close together.
- Keep them out of direct sun and drafts.
- Allow at least 20–30 minutes for temperature equalisation.
- Compare several readings, not one instant value.
- 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
| Feature | AHT20 | DHT22 |
|---|---|---|
| Interface | I²C | Single-wire proprietary timing |
| Typical humidity accuracy | ~±2% RH | Generally poorer class |
| Temperature accuracy | ~±0.3°C | Typically around ±0.5°C class |
| ESP32 integration | Very easy | Easy but timing-dependent |
| Bus sharing | Yes, but fixed address | Separate data pin per sensor |
| Recommended new project | AHT20 | Only 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
| Measurement | Possible use |
|---|---|
| Humidity >70% | Bathroom ventilation notification/control |
| Humidity rising quickly | Detect shower/steam event |
| Temperature too high | Climate/awning/shutter automation |
| Very low humidity | Humidifier reminder |
| Temperature + humidity | Calculate 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
| Symptom | Likely cause / first check |
|---|---|
| No device in I²C scan | Check VCC/GND/SDA/SCL and 0x38 |
| 0x38 detected but no measurements | Set variant: AHT20 |
| Temperature 1–2°C too high | ESP32/regulator/enclosure heating |
| Humidity consistently too low | Sensor is warmer than ambient; fix temperature bias first |
| Humidity drifts after bathroom/greenhouse use | Prolonged high RH/condensation |
| Readings change after gluing enclosure | Volatile adhesive/solvent exposure |
| Cannot add second AHT20 | Both use fixed 0x38 address |
| Verbose ESPHome blocking warning | Documented AHT humidity-read behaviour |
| Values seem noisy | Check placement first; then use light averaging |
| Device goes unavailable, sensor values disappear | Likely 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
- Best Temperature & Humidity Sensor for ESP32 — AHT20 vs SHT45, BME280 and DHT22.
- BMP280 vs BME280 — when pressure measurement is also useful.
- SHT30 vs SHT31 vs SHT35 — Sensirion alternatives.
- ESP32 Weather Station with ESPHome — combine climate sensing with rain, wind and light.
- ESPHome Wi-Fi Disconnects — troubleshoot nodes that disappear from Home Assistant.
Official and Reference Resources
- ESPHome AHT10/AHT20 Component — current AHT20 variant configuration and update interval.
- Aosong AHT20 Datasheet — accuracy, environmental limits, self-heating and application guidance.
- Adafruit AHT20 Guide — breakout wiring and fixed 0x38 I²C address.