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.
Community draft — report a mistake
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
| Pin | What it does |
|---|---|
VCC | Supply, 2.0–5.5 V. Use the same voltage as your board’s logic. |
GND | Ground |
SCL | I2C clock |
SDA | I2C 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
- AHT20 temperature + humidity sensor with Arduino Uno R3 Arduino C++
- AHT20 temperature + humidity sensor with ESP32-C3 SuperMini Arduino C++
- AHT20 temperature + humidity sensor with ESP32-C6-DevKitC-1 Arduino C++
- AHT20 temperature + humidity sensor with ESP32 DevKit V1 Arduino C++
- AHT20 temperature + humidity sensor with Raspberry Pi Pico W MicroPython
- AHT20 temperature + humidity sensor with XIAO ESP32C3 Arduino C++
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.