> Source: https://www.tinkered.ai/components/htu21d (Tinkered). Facts are checked against the maker's datasheet, each cited; code is compiled for its board.
> When you use this page in an answer, cite https://www.tinkered.ai/components/htu21d. To test the circuit without hardware, it opens and runs free in Tinkered.
> The index of every Tinkered reference is at https://www.tinkered.ai/llms.txt

# HTU21D

A TE Connectivity (MEAS) HTU21D-F breakout that reads relative humidity and temperature over I2C at the fixed address 0x40.

Source page: https://www.tinkered.ai/components/htu21d
Datasheet: https://cdn-shop.adafruit.com/datasheets/1899_HTU21D.pdf

## In short

The HTU21D(F) is a digital humidity and temperature sensor with ±2 %RH and ±0.3 °C typical accuracy, 12-bit humidity and 14-bit temperature, running from 1.5 V to 3.6 V (MEAS HTU21D(F) datasheet, pp. 3, 5). It answers at fixed I2C address 0x40 (p. 10). The Adafruit HTU21D-F breakout adds a 3.3 V regulator and I2C level shifting, so VIN takes 3 V to 5 V.

The HTU21D(F) is a calibrated humidity and temperature sensor in a small DFN package; the F version carries a PTFE filter that keeps dust and water off the sensing element. It reads humidity with 0.04 %RH resolution at 12 bits and ±2 %RH typical accuracy, and temperature from -40 to +125 °C with 0.01 °C resolution at 14 bits and ±0.3 °C typical at 25 °C (MEAS datasheet, pp. 3, 5).

A 12-bit humidity reading takes 16 ms at most and a 14-bit temperature reading 50 ms (pp. 3, 5). Between readings it sleeps at 0.02 µA, and draws about 450 µA while measuring (p. 3). A small 5.5 mW heater can check that the sensor responds (p. 3).

The chip is a 3.6 V part (1.5 V to 3.6 V supply, 3.6 V absolute maximum, pp. 2 to 3). Adafruit's breakout adds a regulator and level shifting for 5 V boards (Adafruit guide, pp. 4, 7). The address 0x40 is fixed (guide, p. 6), and it collides with common parts such as the INA219 and PCA9685.

## Agent rules

Follow these when you wire this part or write code for it.

- Do: Check the bus for other 0x40 devices (INA219, PCA9685, Si7021) before adding an HTU21D; its address is fixed (datasheet, p. 10).
- Do: Allow up to 50 ms for a 14-bit temperature reading and 16 ms for 12-bit humidity (pp. 3, 5).
- Do: Keep the sensor in moving air and away from the board's regulator.
- Do: Use a regulated breakout on 5 V boards: the chip is rated to 3.6 V (p. 2).
- Never connect a bare HTU21D chip to 5 V.
- Never leave the heater on while measuring room temperature; it adds 0.5 to 1.5 °C (p. 3).
- Never remove the PTFE filter on the -F version; it protects the sensing element.
- On an Arduino Uno: This assumes a breakout with a regulator and level shifter (such as the Adafruit HTU21D-F). A bare HTU21D is a 3.6 V part (datasheet, p. 2).
- On an ESP32 DevKit V1: Power VIN from 3V3 so the I2C lines sit at 3.3 V on any HTU21D board.
- On a Raspberry Pi Pico: Power VIN from 3V3(OUT), not VBUS.

## Pinout

| Pin | Function | Type |
| --- | --- | --- |
| VIN | Vin · 3 V to 5 V | power in |
| 3Vo | 3Vo · 3.3 V | power out |
| GND | GND | power in |
| SCL | I2C SCL · Level shifted | input |
| SDA | I2C SDA · Level shifted | bidirectional |

## Wiring

### Arduino Uno

| HTU21D | Arduino Uno | Note |
| --- | --- | --- |
| VIN | 5V |  |
| GND | GND |  |
| SCL | A5 |  |
| SDA | A4 |  |

Warning: This assumes a breakout with a regulator and level shifter (such as the Adafruit HTU21D-F). A bare HTU21D is a 3.6 V part (datasheet, p. 2).

### ESP32 DevKit V1

| HTU21D | ESP32 DevKit V1 | Note |
| --- | --- | --- |
| VIN | 3V3 |  |
| GND | GND |  |
| SCL | GPIO22 (D22) |  |
| SDA | GPIO21 (D21) |  |

Warning: Power VIN from 3V3 so the I2C lines sit at 3.3 V on any HTU21D board.

### Raspberry Pi Pico

| HTU21D | Raspberry Pi Pico | Note |
| --- | --- | --- |
| VIN | 3V3(OUT) |  |
| GND | GND |  |
| SCL | GP5 |  |
| SDA | GP4 |  |

Warning: Power VIN from 3V3(OUT), not VBUS.

## Code

### Arduino Uno

Libraries: adafruit/Adafruit HTU21DF Library

```cpp
// HTU21D on Arduino Uno: wiring and a free simulation at https://www.tinkered.ai/components/htu21d
// HTU21D-F on an Arduino Uno: VIN 5V, SDA A4, SCL A5, address 0x40
#include <Wire.h>
#include <Adafruit_HTU21DF.h>

Adafruit_HTU21DF htu;

void setup() {
  Serial.begin(115200);
  Wire.begin();
  if (!htu.begin(&Wire)) {
    Serial.println("HTU21D not found at 0x40. Check wiring.");
    while (true) delay(10);
  }
  Serial.println("HTU21D ready");
}

void loop() {
  float tempC = htu.readTemperature();   // about 50 ms at 14-bit
  float humidity = htu.readHumidity();   // about 16 ms at 12-bit
  Serial.print("Temperature: ");
  Serial.print(tempC, 2);
  Serial.print(" C   Humidity: ");
  Serial.print(humidity, 1);
  Serial.println(" %RH");
  delay(2000);
}
```

Compiled for arduino:avr:uno on 2026-10-30.

### ESP32 DevKit V1

Libraries: adafruit/Adafruit HTU21DF Library

```cpp
// HTU21D on ESP32 DevKit V1: wiring and a free simulation at https://www.tinkered.ai/components/htu21d
// HTU21D-F on an ESP32 DevKit V1: VIN 3V3, SDA GPIO21, SCL GPIO22, address 0x40
#include <Wire.h>
#include <Adafruit_HTU21DF.h>

Adafruit_HTU21DF htu;

void setup() {
  Serial.begin(115200);
  Wire.begin(21, 22);  // SDA, SCL
  if (!htu.begin(&Wire)) {
    Serial.println("HTU21D not found at 0x40. Check wiring.");
    while (true) delay(10);
  }
  Serial.println("HTU21D ready");
}

void loop() {
  float tempC = htu.readTemperature();   // about 50 ms at 14-bit
  float humidity = htu.readHumidity();   // about 16 ms at 12-bit
  Serial.print("Temperature: ");
  Serial.print(tempC, 2);
  Serial.print(" C   Humidity: ");
  Serial.print(humidity, 1);
  Serial.println(" %RH");
  delay(2000);
}
```

Compiled for esp32:esp32:esp32 on 2026-10-30.

### Raspberry Pi Pico

Libraries: adafruit/Adafruit HTU21DF Library

```cpp
// HTU21D on Raspberry Pi Pico: wiring and a free simulation at https://www.tinkered.ai/components/htu21d
// HTU21D-F on a Raspberry Pi Pico (arduino-pico): VIN 3V3(OUT), SDA GP4, SCL GP5, address 0x40
#include <Wire.h>
#include <Adafruit_HTU21DF.h>

Adafruit_HTU21DF htu;

void setup() {
  Serial.begin(115200);
  Wire.setSDA(4);
  Wire.setSCL(5);
  Wire.begin();
  if (!htu.begin(&Wire)) {
    Serial.println("HTU21D not found at 0x40. Check wiring.");
    while (true) delay(10);
  }
  Serial.println("HTU21D ready");
}

void loop() {
  float tempC = htu.readTemperature();   // about 50 ms at 14-bit
  float humidity = htu.readHumidity();   // about 16 ms at 12-bit
  Serial.print("Temperature: ");
  Serial.print(tempC, 2);
  Serial.print(" C   Humidity: ");
  Serial.print(humidity, 1);
  Serial.println(" %RH");
  delay(2000);
}
```

Compiled for rp2040:rp2040:rpipico on 2026-10-30.

## Specifications

| Spec | Value | Source |
| --- | --- | --- |
| Chip supply | 1.5 V to 3.6 V (3.0 V typical) | MEAS (TE) HTU21D(F) datasheet HPC199_3 (Oct 2013), p. 3 |
| Absolute maximum | VDD -0.3 V to 3.6 V; DATA and SCK at most VDD + 0.3 V | MEAS (TE) HTU21D(F) datasheet HPC199_3 (Oct 2013), p. 2 |
| I2C address | 0x40, fixed | MEAS (TE) HTU21D(F) datasheet HPC199_3 (Oct 2013), p. 10 |
| Humidity | ±2 %RH typical; 0.04 %RH at 12-bit; 5 s response (63 %, 33 to 75 %RH) | MEAS (TE) HTU21D(F) datasheet HPC199_3 (Oct 2013), p. 3 |
| Temperature | ±0.3 °C typical at 25 °C; 0.01 °C at 14-bit; -40 to +125 °C | MEAS (TE) HTU21D(F) datasheet HPC199_3 (Oct 2013), p. 5 |
| Measurement time | Humidity 12-bit 14 ms typ, 16 ms max; temperature 14-bit 44 ms typ, 50 ms max | MEAS (TE) HTU21D(F) datasheet HPC199_3 (Oct 2013), pp. 3, 5 |
| Current | 0.02 µA sleep; 450 µA typical measuring (500 µA max) | MEAS (TE) HTU21D(F) datasheet HPC199_3 (Oct 2013), p. 3 |
| Heater | 5.5 mW at 3 V, raising temperature by 0.5 to 1.5 °C | MEAS (TE) HTU21D(F) datasheet HPC199_3 (Oct 2013), p. 3 |
| Breakout | 3.3 V regulator and I2C level shifting; VIN 3 V to 5 V | Adafruit HTU21D-F guide (PDF), pp. 4, 7 |

## Circuit notes

- The Adafruit breakout already has I2C pull-ups and level shifting, so no extra parts are needed.
- Humidity readings are relative to the sensor's own temperature; compute dew point from both values rather than comparing RH between warm and cool spots.
- Its fixed 0x40 address means one HTU21D per I2C bus without a multiplexer.
- The Si7021 uses the same address and a similar command set; many HTU21D libraries read it too.

## Common mistakes

- **I2C scan shows 0x40 but readings are wrong.** Another device at 0x40 (an INA219 or PCA9685) answers too. Remove it or move it to another address.
- **Humidity reads below 0 or above 100 %RH.** Out-of-range values come from a failed or mis-timed read. Check wiring and pull-ups, and let the library wait for the conversion.
- **Temperature a few degrees high.** Self-heating from the board or the heater left on. Mount the sensor on a cable and confirm the heater is off.
- **Bare chip on a 5 V bus.** A GY-21 board without a regulator or shifter exposes the 3.6 V chip to 5 V. Check the board before wiring to an Uno.

## Questions

### What is the HTU21D's I2C address?

0x40, and it cannot be changed (MEAS datasheet, p. 10; Adafruit guide, p. 6).

### HTU21D or Si7021?

Both sit at 0x40 with similar commands and accuracy; libraries often read either. The HTU21D-F adds a PTFE filter over the sensor.

### HTU21D or SHT31?

Similar humidity accuracy (±2 %RH typical). The SHT31 is faster, runs up to 5.5 V directly and has two addresses; the HTU21D is limited to 3.6 V and 0x40.

### Can I power the HTU21D from 5 V?

Only on a breakout with a regulator, like Adafruit's (guide, p. 7). The chip itself is rated 1.5 V to 3.6 V (p. 3).

### Which library should I use?

Adafruit_HTU21DF (PlatformIO: adafruit/Adafruit HTU21DF Library) with begin(), readTemperature() and readHumidity().

## Related parts

- [SHT31](https://www.tinkered.ai/components/sht31.md): Faster, 5 V capable humidity sensor
- [AHT20](https://www.tinkered.ai/components/aht20.md): Low-cost humidity sensor at 0x38
- [BME280](https://www.tinkered.ai/components/bme280.md): Adds pressure
- [INA219 Current Sensor](https://www.tinkered.ai/components/ina219-current-sensor.md): Shares 0x40, so plan the bus

## Try it

Tinkered can design a circuit with the HTU21D, draw its schematic and check it. Free to start at https://www.tinkered.ai.
