Reference
AHT20
Temperature and humidity.
- Connects over
- I²C
- Address
- 0x38
- Made by
- Aosong
- Datasheet
- cdn-shop.adafruit.com
Use it
hardware {
device aht20: AHT20
}
every 1s {
let value: float = aht20.temperature()
log("aht20", "temperature={value}")
}
On its own, the declaration puts the AHT20 on the first I²C bus (SDA 21, SCL 22 on the ESP32) at 0x38. To choose the pins or the address, declare the bus and attach the device: device aht20: AHT20 on i2c0 at 0x38 with i2c i2c0(sda: 21, scl: 22).
Methods
-
aht20.temperature() -> float
Temperature in °C
-
aht20.humidity() -> float
Relative humidity %
Wiring
| Pin | Connect to |
|---|---|
VCC | 3.3V or 5V |
GND | Ground |
SDA | Pull-up to VCC (often on breakout board) |
SCL | Pull-up to VCC |
Specifications
- Voltage
- 2.2V – 5.5V
- Current
- 23 μA measure, 0.25 μA sleep
- Temp range
- −40°C to +85°C ±0.3°C
- Humidity range
- 0–100% RH ±2%
- Interface speed
- I²C up to 400 kHz
Tips
- Address is fixed at 0x38 — only one AHT20 per I²C bus without a multiplexer.
- Needs 40 ms after power-on before the first measurement.
- Replacement for the older AHT10 with better humidity accuracy.
Alternatives worth knowing:
- SHT31: Sensirion equivalent, slightly more accurate, costlier.
- BME280: Adds pressure on top of T/H if you need altitude.