Source: https://mokxi.com/parts/aht20
Updated: 2026-11-10

Part

# Humidity sensor, AHT20

Temperature and humidity over I2C at 0x38, one 80 ms measurement at a time.

See every part

- 4 pins
- 2 settings
- In 2 projects
- In 1 lesson

Drawn live by the editor's own code, at the size you see it.

At a glance

## The Humidity sensor, AHT20 in brief

What it is, and every setting the properties panel gives it.

The AHT20 is the temperature and humidity sensor that replaces the DHT11 in newer kits. It measures the same two things more accurately, and it does it over I2C at address 0x38, so it shares two wires with a display instead of needing a pin and a timing-critical protocol of its own. It has no registers: a write is a command and a read is the status byte followed by the data. Mokxi models the sequence as ASAIR’s datasheet gives it. Power-on takes up to 20 ms, during which the address is not acknowledged. A measurement is triggered with 0xAC 0x33 0x00, takes 80 ms and sets the busy bit the whole time, and the six bytes that follow hold two 20-bit counts and a CRC-8. Humidity is the count over 2 to the 20th times 100 percent, and temperature is the count over the same times 200, less 50. Two sliders move the weather. The accuracy figures, the response time and self-heating are not modeled.

Family

Sensors

Pins

4

temperature

22

humidity

45

Pins

## 4 pins

Named as the editor names them, so a wire lands where you expect it.

Pin

What it does

VCC

Supply, 2.0 V to 5.5 V.

GND

Ground.

SCL

I2C clock. The module carries the pull-ups.

SDA

I2C data.

How to use it

## How to use an AHT20 sensor with an Arduino and an LCD

The AHT20 has four pins: VCC, GND, SDA and SCL. The module carries the pull-ups. In the built-in project it goes to the Uno’s 5 V and to A4 and A5, and a 16x2 I2C LCD sits on the same two wires, because each device answers only its own address, 0x38 for the sensor and 0x27 for the display. A TTP223 touch pad on pin 2 flips the reading between Celsius and Fahrenheit, on the rising edge so a held finger flips it once.

Adafruit_AHTX0 asks for a reading and waits the 80 ms the chip takes to make one. The sketch takes the numbers in hundredths, getTemperatureCentis() and getHumidityCentis(), because Fahrenheit is then an integer sum, F times 100 equals C times 100 times 9 over 5 plus 3200, and the Uno has no floating point hardware. Sums on the library’s float readings link only on the Uno R4, so use the centis calls elsewhere.

Do not read the chip straight after the trigger. A read before 80 ms has the busy bit set and returns the old data, and the datasheet asks for a reading no more often than every 2 seconds because of self-heating, which the simulation does not model. A slider moved between measurements shows up in the next one, never the one already taken. The chip powers up calibrated, reading 0x18 when idle.

Part pin

Board pin

VCC

5 V (2.0 V to 5.5 V)

GND

Ground

SDA

Uno A4

SCL

Uno A5

LCD backpack

The same SDA and SCL, address 0x27

Touch pad SIG

Uno pin 2

The chip runs from 2.0 V to 5.5 V, so a 3.3 V ESP32 or Pico powers it directly. Floats print on every board, but arithmetic on them links only on the Uno R4.

Hold the button

This is the simulator itself, running here. Click anything to open it in the editor.

Open this project in the editor Read the full tutorial

Reading temperature and humidity

Common errors

## Common Humidity sensor, AHT20 errors and fixes

What goes wrong

The fix

begin() fails right after power-up.

The chip needs up to 20 ms after power-on before it acknowledges its address. Delay before begin(), or retry.

A reading right after the trigger is old or wrong.

A measurement takes 80 ms and the busy bit is set the whole time. Wait for it, or let the library do it with getEvent().

Fahrenheit arithmetic fails to link on an Uno.

Sums on the float readings link only on the Uno R4. Use getTemperatureCentis() and work in hundredths.

The values barely change when you move a slider.

A slider moved between measurements shows up in the next one, never the one already taken. Wait for the next reading.

Questions

## Questions and answers

### Is the AHT20 a replacement for the DHT11?

For most kits, yes. It measures temperature and humidity more accurately and sits on I2C, so it needs two wires shared with other devices instead of its own pin and protocol.

### What is the AHT20’s I2C address?

0x38, fixed. A display at 0x27 or 0x3C can share the bus with it.

### How long does a measurement take?

80 ms from the trigger 0xAC 0x33 0x00, with the busy bit set the whole time. Reading sooner returns stale data.

### Which library reads the AHT20?

Adafruit_AHTX0. getEvent() fills a temperature and a humidity event, and getTemperatureCentis() and getHumidityCentis() return the same reading in hundredths.

How it is modeled

## What is true about the Humidity sensor, AHT20, here

In its help article’s own words: what the simulation gets right, and where it stops.

### Modeled

The command set, the 20 ms power-on and reset times, the 80 ms measurement with its
busy bit, the bit packing and the CRC, all from the ASAIR datasheet (V1.1). The chip
powers up calibrated (status bit 3 set), as the parts sold do, and reads 0x18 when
idle.

### Not modeled

The accuracy figures (±2 %RH and ±0.3 °C typical), the 8 s humidity response time,
and self-heating, which is why the sheet asks for a reading no more often than every
2 seconds.

From AHT20 temperature and humidity sensor, in full.

Projects

## See the Humidity sensor, AHT20 in a project

2 built-in projects use it. Each opens in the editor, already wired.

Lessons

## Where it turns up in a lesson

One lesson places it in its own circuit.

### Learn articles

1 lesson

- Arduino Touch Sensor (TTP223): Wiring and Code

Boards

## The boards it is shown on

This board has a built-in project with the Humidity sensor, AHT20 in it.

- Arduino Uno R3

Libraries

## Arduino libraries for the Humidity sensor, AHT20

Built in, so the sketch compiles with nothing to install. Each page has the calls, the wiring and an example to run.

- Adafruit AHTX0
- DHT20

Keep going

## Keep going

- I2C Explained: Addresses, Acknowledges and Pull-Ups
- Arduino Touch Sensor (TTP223): Wiring and Code
- Temperature and humidity, SHT31
- Pressure, humidity and temperature, BME280
- Touch sensor, TTP223

More parts

## The rest of the bench

Every one of these is drawn and simulated the same way.

Full-size breadboard

A real 0.1 inch grid with the rails and the center channel, 63 columns wide.

Jumper wires

Drag from any pin or hole to any other. Corners snap, and you can drag them.

Power

A supply rail at the voltage you choose.

Ground

The other end of every circuit.

LED

Lights when current flows. Five colors, and the brightness is what your eye would see.

Filament lamp

A tungsten bulb in a holder: an inrush when it is switched on cold, tens of milliseconds to warm up, and dim on half its voltage.

Resistor

Any value you like, with the color bands drawn to match.

ESP32-C3-DevKitM-1

A RISC-V board that runs your firmware at 160 MHz on the real memory map.

Pushbutton

A 12 mm tactile switch. Hold it while the simulation runs.

Raspberry Pi Pico

The RP2040 board on our own Cortex-M0+ core. Pick a program and press Run.

Raspberry Pi Pico W

Raspberry Pi Pico W (RP2040). The same board and the same pinout as a Pico, with the CYW43439 on it. The WiFi is simulated (no radio; real internet through the Cloud panel’s switch), and the on-board LED, which hangs off that chip rather than off GP25, is driven through the same path. Everything else is the Pico.

Raspberry Pi 4 Model B

Raspberry Pi 4 Model B: the 40-pin header, driven by main.py with RPi.GPIO or gpiozero.

See every part

## Wire up the Humidity sensor, AHT20

Open the editor and push it into the breadboard. It is free, and it runs on your own machine.

Start building free Open the editor
