Preview build — page text is a draft awaiting human review. Code badges come from real compiles. The flasher is real but not yet hardware-tested; the Playground is still a preview.

AHT20 temperature + humidity sensor

AHT20 I2C temperature and humidity module: pin order, fixed address 0x38, 3.3 V vs 5 V wiring and the Adafruit AHTX0 library.

I2C

Community draft — report a mistake

CategorySensor
InterfaceI2C
Voltage2.0–5.5 V
Typical price₹150

3.3 V or 5 V? Most AHT20 breakouts have pull-ups to their own VCC. On ESP32, Pico and other 3.3 V boards, power the module from 3.3 V so SDA/SCL never rise above 3.3 V.

The AHT20 is a small digital temperature and humidity sensor with an I2C interface. It replaces the older AHT10 and is a good, cheaper step up from the DHT11: typical accuracy is about ±2 % RH and ±0.3 °C, and there is no timing-sensitive single-wire protocol to fight with.

The address is fixed at 0x38, so you can only use one AHT20 per I2C bus. If you need two, put an I2C multiplexer (TCA9548A) in front of them.

Mount the sensor away from the board’s regulator and the ESP32 module — both run warm and will bias the temperature reading by a degree or more.

Pinout

PinWhat it does
VCCSupply, 2.0–5.5 V. Use the same voltage as your board’s logic.
GNDGround
SCLI2C clock
SDAI2C data

I2C address:0x38

Library

Adafruit AHTX0 by Adafruit
Arduino IDE → Library Manager → search the name above. Each guide lists the exact version we compile against.

Use it with

Common errors

Sensor not found at 0x38

Check the pin order on your board — some AHT20 breakouts print GND first. Run the I2C scanner; the AHT20 always answers at 0x38.

Combo board shows two addresses

The popular AHT20 + BMP280 board has two chips: 0x38 is the AHT20, 0x77 (or 0x76) is the BMP280. Use both libraries.

Humidity stuck at 0 % or 100 %

A reading straight after power-up can be wrong. Wait about 100 ms after begin() and keep at least 2 s between reads so the sensor doesn’t self-heat.

Code written for the AHT10 doesn’t work

The AHT10 and AHT20 use slightly different start-up commands. Use the Adafruit AHTX0 library, which handles both.

↑↓ to move · Enter to open