# AHT21B temperature and humidity sensor: specs and pinout

> A digital I2C temperature and relative humidity sensor from Aosong (ASAIR), with calibrated output, on a small module.

[HTML version](https://soldr.ai/docs/components/aht21b)

[Docs](https://soldr.ai/docs) / [Components](https://soldr.ai/docs/components)

A digital I2C temperature and relative humidity sensor from Aosong (ASAIR), with calibrated output, on a small module.

Every value cites its sourceChip-level pinout

[Buy on Compoden](https://compoden.com/products/aht21b-temperature-humidity-sensor-module-i2c-high-accuracy)

## Specs

| Spec | Value | Source |
|---|---|---|
| Supply voltage VCC | 2.0 V to 5.5 V (typical 3.3 V) | source Table 2 Electric Specification (p.2); section 3.1 (p.5) |
| Interface | I2C, standard two-wire protocol | source Table 2 (p.2) |
| I2C device address | 0x38 (7-bit) | source section 5.3 (p.7) |
| I2C clock | 0 to 100 kHz standard, up to 400 kHz fast mode | source Table 8 (p.6) |
| Humidity range and resolution | 0 to 100 %RH (extended range; normal operating range is 0-80 %RH), resolution 0.024 %RH | source Table 1 Humidity Characteristics and note 3 (p.2) |
| Humidity accuracy | typical +/-2 %RH at 25 C, 3.3 V (maximum per Figure 2) | source Table 1 and Figure 2 (p.2) |
| Temperature range and resolution | -40 C to 80 C (extended range), resolution 0.01 C | source Table 3 Temperature Characteristics (p.2) |
| Measurement current | 320 uA typical while measuring; 250 nA max dormant (3.3 V, below 60 C) | source Table 2 and note 5 (p.2) |
| Power-up wait | up to 20 ms to idle state; wait 40 ms after power-on before reading | source sections 5.1 (p.6) and 5.4 (p.7) |

## Power

| | Value | Source |
|---|---|---|
| Supply | 2.0 V to 5.5 V, 3.3 V recommended | source Table 2 (p.2), section 3.1 (p.5) |
| Current | 320 uA while measuring | source Table 2 (p.2), section 3.1 (p.5) |

## Chip pins
These are the pins of the chip on the module, from the chip datasheet. The module's own header may label or expose them differently.

The Aosong sheet describes the AHT21B sensor part. The module board (regulator, pull-ups, header order) is not covered by an official document, so check the labels printed on your module.

| Pin | Function | Voltage | Notes | Source |
|---|---|---|---|---|
| VCC | Supply Voltage | 2.0 V to 5.5 V | Table 5 lists the sensor&#x27;s pins (VCC, SDA, GND, SCL) | source Table 5, section 3 (p.5) |
| SDA | Serial Data, Bidirectional | VCC level | Aosong sensor part: pull-up is included in the sensor&#x27;s internal circuit per section 3.3; pull-up voltage must be VCC | source Table 5, section 3.3 (p.5) |
| GND | Power ground | 0 V | | source Table 5 (p.5) |
| SCL | Serial Clock, Bidirectional | VCC level | | source Table 5 (p.5) |

## Build with it
Project ideas for the AHT21B temperature and humidity sensor. Each link opens Soldr with the prompt filled in; Soldr assigns the pins, checks power and shows how to wire every part.

- [Room climate display](https://app.soldr.ai/?prompt=I%20want%20to%20build%20a%20room%20temperature%20and%20humidity%20display%20with%20an%20ESP32%2C%20an%20AHT21B%20sensor%20and%20an%20OLED): The sensor accepts 2.0 to 5.5 V and runs I2C at the supply level, so it shares a 3.3 V I2C bus with the OLED.
- [Wi-Fi cupboard humidity logger](https://app.soldr.ai/?prompt=I%20want%20to%20build%20a%20wardrobe%20humidity%20logger%20with%20a%20NodeMCU%20ESP8266%20and%20an%20AHT21B%20sensor%20that%20posts%20readings%20over%20Wi-Fi): Readings change slowly, so one read every few seconds is plenty. Keep the sensor away from adhesives and solvents, which raise readings per the sheet&#x27;s note 4.
- [Humidity threshold buzzer](https://app.soldr.ai/?prompt=I%20want%20to%20build%20a%20high-humidity%20reminder%20with%20an%20ESP32%2C%20an%20AHT21B%20sensor%20and%20an%20active%20buzzer): A learning project: the buzzer sounds when humidity crosses a limit you set.
- [Climate readout on an LCD](https://app.soldr.ai/?prompt=I%20want%20to%20build%20a%20temperature%20and%20humidity%20readout%20with%20an%20Arduino%20UNO%20R4%20WiFi%2C%20an%20AHT21B%20sensor%20and%20a%2016x2%20I2C%20LCD): The sensor supply range covers 5 V; confirm your module board&#x27;s own regulator before wiring it to a 5 V bus.

## Common mistakes

- Power the sensor before or together with SDA/SCL. The sheet says VCC must come up first or at the same time, otherwise leakage through the signal lines can leave the chip in a bad state after power-on (source: [link](https://aosong.com/userfiles/files/media/AHT21B_%E8%8B%B1%E6%96%87%E7%89%88-%E5%8E%BB%E6%BB%A4%E6%B3%A2%E4%B8%8A%E6%8B%89%2020201217.pdf), section 3.1, p.5).
- Do not read straight after power-on. Wait 40 ms, check the calibration bit with status command 0x71, and send the 0xBE initialise command if it is not set (source: [link](https://aosong.com/userfiles/files/media/AHT21B_%E8%8B%B1%E6%96%87%E7%89%88-%E5%8E%BB%E6%BB%A4%E6%B3%A2%E4%B8%8A%E6%8B%89%2020201217.pdf), section 5.4, p.7).
- Fixed I2C address 0x38: the sheet gives no address-select pin, so two of these cannot share one bus (source: [link](https://aosong.com/userfiles/files/media/AHT21B_%E8%8B%B1%E6%96%87%E7%89%88-%E5%8E%BB%E6%BB%A4%E6%B3%A2%E4%B8%8A%E6%8B%89%2020201217.pdf), section 5.3, p.7).

## Not covered by the official source

- Module board is not documented by an official source; no module pinout order given.
- The typical temperature accuracy figure in Table 3 prints as &#x27;+/-3&#x27; (likely a typo), so no value is given.

## Sources

- [link](https://aosong.com/userfiles/files/media/AHT21B_%E8%8B%B1%E6%96%87%E7%89%88-%E5%8E%BB%E6%BB%A4%E6%B3%A2%E4%B8%8A%E6%8B%89%2020201217.pdf) (AHT21B Product manuals, V1.0; Aosong/ASAIR)
