Overview

The AHT20 (and its predecessor AHT10) is a digital MEMS temperature and humidity sensor manufactured by ASAIR (Aosong Electronics). Equipped with a custom ASIC signal processing chip, a capacitive MEMS humidity sensing element, and an on-chip temperature sensor, the AHT20 delivers factory-calibrated digital measurements over an I2CI^2C bus.

Providing higher accuracy (±0.3C\pm 0.3^\circ\text{C} temperature, ±2% RH\pm 2\%\text{ RH} relative humidity), lower power consumption, and standard SMD packaging at a low cost, the AHT20 has emerged as a popular replacement for older legacy sensors like the DHT11 and DHT22 in indoor air-quality monitors, smart thermostats, and ESPHome weather stations.

Quick reference

Operating voltage (VCC)2.0 V to 5.5 V DC
InterfaceI2CI^2C (Standard Mode 100 kHz / Fast Mode 400 kHz)
I2CI^2C Address0x38 (Fixed)
Temperature range40C-40^\circ\text{C} to +85C+85^\circ\text{C} (±0.3C\pm 0.3^\circ\text{C} typ.)
Humidity range0%0\% to 100% RH100\%\text{ RH} (±2% RH\pm 2\%\text{ RH} typ.)
Measurement current0.98 mA0.98\text{ mA} active / 0.25 μA0.25\ \mu\text{A} standby
Response timet63%8 st_63\% \le 8\text{ s}

Pinout

Breakout modules feature a standard 4-pin 0.1" (2.54 mm) header or Qwiic / STEMMA QT connector:

PinNameTypeDescription
1VCCPowerSupply voltage (+2.0 V to +5.5 V DC)
2GNDPowerGround (0 V)
3SCLDigital InputI2CI^2C Serial Clock (requires pull-up resistor)
4SDADigital Input / OutputI2CI^2C Serial Data (requires pull-up resistor)

Specifications

ParameterSymbolMinTypMaxUnitConditions
Supply VoltageVCCV_{CC}2.03.3 / 5.05.5VDC
Supply Current (Measuring)ICCI_{CC}0.981.5mAVCC=3.3 VV_{CC} = 3.3\text{ V} during conversion
Supply Current (Standby)IsbI_{sb}0.251.0µASleep state
Temperature ResolutionTresT_{res}0.01°C20-bit output
Temperature AccuracyTaccT_{acc}-0.3±0.3\pm 0.3+0.3°C0C0^\circ\text{C} to 55C55^\circ\text{C}
Relative Humidity ResolutionRHresRH_{res}0.024% RH20-bit output
Relative Humidity AccuracyRHaccRH_{acc}-2.0±2.0\pm 2.0+2.0% RHAt 25C25^\circ\text{C}, 10%–90% RH
I2CI^2C Clock FrequencyfSCLf_{SCL}0100400kHzStandard / Fast mode

I2CI^2C Communication & Protocol

The AHT20 uses a fixed 7-bit I2CI^2C address of 0x38.

  1. Initialization: Upon power-up (VCC>2.0VV_{CC} > 2.0\text{V}), wait 40 ms. Read status byte. If bit 3 (0x08) is 0, send initialization command 0xBE 0x08 0x00 and wait 10 ms.
  2. Trigger Measurement: Send 3-byte command sequence 0xAC 0x33 0x00.
  3. Read Data: Wait 80 ms for measurement completion. Read 7 bytes from 0x38:
    • Byte 0: Status byte (bit 7 = Busy flag: 0 ready, 1 measuring).
    • Bytes 1–3: 20-bit Raw Humidity data (SRHS_{RH}).
    • Bytes 3–5: 20-bit Raw Temperature data (STS_{T}).
    • Byte 6: CRC-8 checksum.

Conversion Formulas

Relative Humidity (% RH)=(SRH220)×100%\text{Relative Humidity (\% RH)} = \left( \frac{S_{RH}}{2^{20}} \right) \times 100\%

Temperature (C)=(ST220)×20050\text{Temperature } (^\circ\text{C}) = \left( \frac{S_{T}}{2^{20}} \right) \times 200 - 50

Wiring

Sensor PinArduino UnoESP32Notes
VCC5V / 3.3V3.3VWide 2.0V–5.5V supply range
GNDGNDGNDShared ground
SCLA5GPIO 22I2CI^2C Clock (4.7 kΩ4.7\text{ k}\Omega pull-up recommended)
SDAA4GPIO 21I2CI^2C Data (4.7 kΩ4.7\text{ k}\Omega pull-up recommended)

Example

cpp
#include <Wire.h>
#include <Adafruit_AHTX0.h>

Adafruit_AHTX0 aht;

void setup() {
  Serial.begin(9600);
  while (!Serial) delay(10);

  Serial.println("Initializing AHT20 Sensor...");
  if (!aht.begin()) {
    Serial.println("Could not find AHT20 sensor! Check wiring.");
    while (1) delay(10);
  }
  Serial.println("AHT20 initialized successfully.");
}

void loop() {
  sensors_event_t humidity, temp;
  aht.getEvent(&humidity, &temp);

  Serial.print("Temperature: ");
  Serial.print(temp.temperature);
  Serial.print(" °C | Humidity: ");
  Serial.print(humidity.relative_humidity);
  Serial.println(" %RH");

  delay(2000);
}

Common mistakes

  • Not waiting 80 ms after measurement trigger: Reading bytes before the busy bit (Status Bit 7) drops to 0 returns stale or zeroed 20-bit sensor payloads.
  • Conflating AHT10 and AHT20 initialization commands: AHT10 uses 0xE1 0x08 0x00 while AHT20 requires 0xBE 0x08 0x00. Modern libraries auto-detect and send the correct byte sequence.
  • Condensation on MEMS element: Exposure to liquid water drops shifts capacitive readings temporarily. Allow the sensor 24 hours in dry ambient air to recover.

Notes

  • AHT20 vs SHT31: AHT20 offers comparable accuracy to Sensirion's SHT30/SHT31 at a lower unit cost, making it ideal for high-volume IoT nodes.

Assets & downloads