Overview

The HTU21D (and HTU21DF variant with PTFE filter membrane) is a digital relative humidity and temperature sensor manufactured by TE Connectivity (formerly Measurement Specialties). Housed in a tiny 3.0×3.0 mm3.0 \times 3.0\text{ mm} 6-pin DFN package, it is widely used in weather stations, home automation HVAC controllers, and medical equipment.

Delivering typical accuracies of ±2% RH\pm 2\%\ \text{RH} and ±0.3C\pm 0.3^\circ\text{C}, user-programmable resolution (12-bit RH / 14-bit Temp down to 8-bit / 11-bit), CRC-8 checksum verification, an onboard heating element, and an I2CI^2C interface (0x40), the HTU21D draws an ultra-low standby current of 0.14 μA0.14\ \mu\text{A}.

Quick reference

Operating voltage (VCC)3.3 V to 5.0 V DC (breakout includes 3.3V LDO regulator)
IC supply voltage (VDD)1.5 V to 3.6 V DC (3.3 V nominal)
InterfaceI2CI^2C Fast-Mode (up to 400 kHz)
Fixed I2CI^2C address0x40
Humidity range & accuracy0% to 100% RH0\%\text{ to }100\%\text{ RH} (±2% RH\pm 2\%\ \text{RH} typical)
Temperature range & accuracy40C to +125C-40^\circ\text{C}\text{ to }+125^\circ\text{C} (±0.3C\pm 0.3^\circ\text{C} typical)
Resolution options12-bit RH / 14-bit Temp (Default) or 8-bit RH / 11-bit Temp
Internal heaterOnboard programmable heater for sensor diagnostic & de-fogging
Standby current0.14 μA0.14\ \mu\text{A} typical at VDD=3.0VVDD = 3.0\text{V}

Pinout

Breakout module 4-pin header:

PinNameTypeDescription
1VINPowerSupply power input (+3.3 V to +5.0 V DC)
2GNDPowerGround reference (0 V)
3SCLDigital InputI2CI^2C Serial Clock
4SDADigital Input / OutputI2CI^2C Serial Data

Specifications

ParameterSymbolMinTypMaxUnitConditions
Supply Voltage (Module)VVINV_{VIN}3.33.3 / 5.05.5VPower rail with LDO
Active CurrentICCI_{CC}450500µAActive conversion state
Standby CurrentIsdI_{sd}0.140.5µASleep mode
RH Accuracy (20%80%20\%\dots 80\%)RHaccRH_{acc}-2.0±2.0\pm 2.0+2.0% RHAt 25C25^\circ\text{C}
Temp Accuracy (0C60C0^\circ\text{C}\dots 60^\circ\text{C})TaccT_{acc}-0.3±0.3\pm 0.3+0.3°CAt 25C25^\circ\text{C}
Measuring Time (14-bit Temp)ttempt_{temp}4450msMax resolution
Measuring Time (12-bit RH)trht_{rh}1416msMax resolution

I2CI^2C Command Opcodes & Math

  • Trigger Temperature Measure (Hold Master): 0xE3
  • Trigger Humidity Measure (Hold Master): 0xE5
  • Trigger Temperature Measure (No Hold): 0xF3
  • Trigger Humidity Measure (No Hold): 0xF5

Temperature Calculation (C^\circ\text{C})

Temperature (C)=46.85+175.72×(Raw 16-bit Temp Register & 0xFFFC65536)\text{Temperature } (^\circ\text{C}) = -46.85 + 175.72 \times \left( \frac{\text{Raw 16-bit Temp Register \& 0xFFFC}}{65536} \right)

Humidity Calculation (% RH\%\text{ RH})

Relative Humidity (% RH)=6.0+125.0×(Raw 16-bit RH Register & 0xFFFC65536)\text{Relative Humidity } (\%\text{ RH}) = -6.0 + 125.0 \times \left( \frac{\text{Raw 16-bit RH Register \& 0xFFFC}}{65536} \right)

Wiring

HTU21D PinArduino / MCUESP32Notes
VIN5V / 3.3V3.3VPower rail
GNDGNDGNDSystem ground
SCLA5GPIO 22I2CI^2C Clock
SDAA4GPIO 21I2CI^2C Data

Example (Adafruit_HTU21DF Library)

cpp
#include <Wire.h>
#include "Adafruit_HTU21DF.h"

Adafruit_HTU21DF htu = Adafruit_HTU21DF();

void setup() {
  Serial.begin(115200);
  Serial.println("Adafruit HTU21D-F Humidity & Temp Test");

  if (!htu.begin()) {
    Serial.println("Couldn't find HTU21D-F sensor! Check I2C wiring.");
    while (1);
  }
}

void loop() {
  float temp = htu.readTemperature();
  float rel_hum = htu.readHumidity();

  Serial.print("Temp: "); Serial.print(temp); Serial.print(" °C | ");
  Serial.print("Humidity: "); Serial.print(rel_hum); Serial.println(" % RH");

  delay(1000);
}

Common mistakes

  • Holding finger near sensor element: Human skin radiates moisture (70% RH\ge 70\%\text{ RH}) and thermal heat. Keep hands clear of the small white PTFE sensor filter while taking ambient room measurements.
  • Forgetting I2C bus address collision: HTU21D uses fixed address 0x40, which collides with HDC1080 and Si7021 sensors if placed on the same I2CI^2C bus.

Notes

  • HTU21D vs Si7021 vs SHT31: HTU21D is fully command-compatible with the Si7021; SHT31 offers higher accuracy (±1.5% RH\pm 1.5\%\text{ RH}) and configurable I2CI^2C addresses (0x44/0x45).

Assets & downloads