Component guide · Beginner · 4 min read
AHT30, AHT21, AHT25, DHT20 and WHT20 I2C Temperature and Humidity Sensors

Wiring and Code
By Geekobot Learning Team · Updated 29 Oct 2026
On this page
The AHT30, AHT21, AHT25 and DHT20 are small calibrated I2C temperature and humidity sensors from the same family as the AHT20. They all sit at I2C address 0x38, run on 2.2 to 5.5 V and give about plus or minus 2 percent RH and 0.3 degrees C. The DHT20 is the I2C replacement for the DHT11, and the probe versions put the sensor in a vented steel tube.
Key specs at a glance
- Supply
- 2.2 to 5.5 V (check the module)
- Interface
- I2C, address 0x38
- Humidity
- 0 to 100% RH, about plus or minus 2 to 3% RH
- Temperature
- -40 to 85 degrees C, about plus or minus 0.3 degrees C
- Response
- About 5 to 8 s for humidity
- Current
- Under 1 mA while measuring
Models in this guide
These are alternatives. Pick the one that fits your project; you only need one.
Option 1AHT30 Temperature Humidity Sensor Module – Digital I2C Interface₹83
Option 2AHT30 Stainless Steel Probe Line 1 Meter – I2C Digital Temperature & Humidity Sensor₹209
Option 3AHT30 White Shell Built-in Cotton Core Temperature & Humidity Sensor with Card Holder – 1m Cable, I2C Digital Output₹489
Option 4Asair AHT21B Temperature & Humidity Sensor -40~+80°C, 0~100%RH, I2C Digital Output₹125
Option 5Asair AHT25 Temperature & Humidity Sensor -40~+80°C₹138
Option 6Asair DHT20 SIP Temperature & Humidity Sensor -40~+80°C – I2C Interface₹101
What the AHT30, AHT21, AHT25 and DHT20 sensors is
The AHT30, AHT21, AHT25 and DHT20 are factory-calibrated temperature and humidity sensors that talk I2C at address 0x38, the modern replacement for the DHT11.
All of these chips use the same command sequence: send 0xAC 0x33 0x00, wait about 80 ms, then read 6 or 7 bytes. That is why AHT20 libraries usually read the AHT21, AHT25, DHT20 and WHT20 without changes. The AHT30 adds a CRC byte; pick a library that names it if readings look stuck.
The DHT20 is an AHT20 in the old DHT11 SIP package, so it fits the same holes but needs SDA and SCL instead of one data wire. The white-shell and steel probe versions protect the chip in greenhouses and cold rooms while letting air reach it.
AHT30, AHT21, AHT25 and DHT20 sensors pinout
The pins on the AHT30, AHT21, AHT25 and DHT20 sensors and what each one does.
| Pin | Function |
|---|---|
| VCC / VDD | 2.2 to 5.5 V |
| SDA | I2C data |
| GND | Ground |
| SCL | I2C clock |
- VCC / VDD
- 2.2 to 5.5 V
- SDA
- I2C data
- GND
- Ground
- SCL
- I2C clock
Wiring the AHT30, AHT21, AHT25 and DHT20 sensors
Bare chips and the DHT20 need 4.7 k to 10 k pull-ups on SDA and SCL; most modules already have them. Only one AHT can sit on a bus because the address is fixed.
| AHT30, AHT21, AHT25 and DHT20 sensors pin | Arduino Uno | ESP32 |
|---|---|---|
| VCC | 5 V (or 3.3 V) | 3.3 V |
| GND | GND | GND |
| SDA | A4 | GPIO 21 |
| SCL | A5 | GPIO 22 |
- VCC
- Arduino Uno:
- 5 V (or 3.3 V)
- ESP32:
- 3.3 V
- GND
- Arduino Uno:
- GND
- ESP32:
- GND
- SDA
- Arduino Uno:
- A4
- ESP32:
- GPIO 21
- SCL
- Arduino Uno:
- A5
- ESP32:
- GPIO 22
Example code
A minimal sketch to check the part works.
#include <Adafruit_AHTX0.h>
Adafruit_AHTX0 aht;
void setup() {
Serial.begin(115200);
if (!aht.begin()) { Serial.println("No AHT at 0x38"); while (1); }
}
void loop() {
sensors_event_t hum, temp;
aht.getEvent(&hum, &temp);
Serial.print(temp.temperature, 1); Serial.print(" C ");
Serial.print(hum.relative_humidity, 1); Serial.println(" %RH");
delay(2000);
}Setup and tuning
use a library for the AHT20 family (such as Adafruit AHTX0 or the DHT20 library); they share the same commands.
most modules have I2C pull-ups. If you chain several boards, remove extra pull-ups or the bus may misbehave.
all these sensors are fixed at 0x38, so use an I2C multiplexer (TCA9548A) for more than one.
keep the sensor away from the microcontroller and regulator, which warm the air and lower the humidity reading.
wait about 2 seconds between readings so self-heating does not skew temperature.
What you need
Shop this list13 of 14 found in our store · ₹2,872
AHT30 Temperature Humidity Sensor Module – Digital I2C Interface: the part this guide coversAHT30 Temperature Humidity Sensor Module – Digital I2C Interface₹83
Generic AHT30 Stainless Steel Probe Line 1 Meter – I2C Digital Temperature & Humidity Sensor: another version this guide coversAHT30 Stainless Steel Probe Line 1 Meter – I2C Digital Temperature & Humidity Sensor₹209
AHT30 White Shell Built-in Cotton Core Temperature & Humidity Sensor with Card Holder – 1m Cable, I2C Digital Output: another version this guide coversAHT30 White Shell Built-in Cotton Core Temperature & Humidity Sensor with Card Holder – 1m Cable, I2C Digital Output₹489
Asair AHT21B Temperature & Humidity Sensor -40~+80°C, 0~100%RH, I2C Digital Output: another version this guide coversAsair AHT21B Temperature & Humidity Sensor -40~+80°C, 0~100%RH, I2C Digital Output₹125
Asair AHT25 Temperature & Humidity Sensor -40~+80°C: another version this guide coversAsair AHT25 Temperature & Humidity Sensor -40~+80°C₹138
Asair DHT20 SIP Temperature & Humidity Sensor -40~+80°C – I2C Interface: another version this guide coversAsair DHT20 SIP Temperature & Humidity Sensor -40~+80°C – I2C Interface₹101
Elecrow Crowtail – DHT20 Temperature and Humidity Sensor Module: another version this guide coversElecrow Crowtail – DHT20 Temperature and Humidity Sensor Module₹309
Winsen WHT20 Temperature & Humidity Sensor – SMD Package, I2C Interface: another version this guide coversWinsen WHT20 Temperature & Humidity Sensor – SMD Package, I2C Interface₹89
Asair AHT2415C Temperature and Humidity Probe – 304 Stainless Steel Shell, I2C Interface: another version this guide coversAsair AHT2415C Temperature and Humidity Probe – 304 Stainless Steel Shell, I2C Interface₹299- Uno R3 development board: the controller used in the wiring tableFind this part
ESP32-WROOM-32 38-pin development board: for Wi-Fi logging and dashboardsESP32-WROOM-32 38-Pin Development Board₹389
Resistor assortment kit (30 values): pull-up and divider resistorsResistor Assortment Kit (30 Values)₹33
0.96 inch OLED display 128x64: to show readings without a computer0.96" OLED Display 128x64₹139Closest match, check the specs
DFRobot Fermion AHT20 breakout: a ready-made I2C humidity breakoutDFRobot Fermion AHT20 Temperature Humidity Sensor Breakout – I2C Interface₹469
Alternatives and when to choose them
- AHT20 sensor: the original chip this family builds on.
- DHT11 vs DHT22: single-wire sensors the DHT20 replaces.
- SHT3x sensors: higher accuracy, selectable address.
Common mistakes to avoid
- Putting two 0x38 sensors on one I2C bus.
- Mounting the sensor right above the ESP32 or regulator.
- Reading many times a second, which warms the sensor.
- Leaving a bare board outdoors in rain or direct sun.
Frequently asked questions
Is the DHT20 the same as the DHT11?
No. The DHT20 is an I2C sensor with much better accuracy; it shares the DHT name and case, not the single-wire protocol.
Can I use two AHT sensors on one Arduino?
Not on the same I2C bus, because both use address 0x38. Use a TCA9548A multiplexer or a second I2C bus.
Does the AHT30 work at 3.3 V?
Yes. The family runs from about 2.2 to 5.5 V, so it works with ESP32, Pico and 5 V Arduinos.
Why does my humidity read too low?
The sensor is probably warmed by nearby electronics. Move it away from the board or into a vented housing.
Which one suits outdoor use?
Use a probe version in a vented radiation shield; bare boards fail in rain and direct sun.
Parts for this guide
Keep learning
Sources
Written by the Geekobot team from manufacturer datasheets. Always check the datasheet for the exact part and variant you buy.

