Component guide · Beginner · 3 min read
HTU21D Humidity and Temperature Sensor

Pinout, Wiring and Code
By Geekobot Learning Team · Updated 29 Oct 2026
On this page
The HTU21D from TE Connectivity is a small digital humidity and temperature sensor that talks I2C at address 0x40. It measures 0 to 100 % RH and −40 to 125 °C with ±0.3 °C typical accuracy. It is a good upgrade from the DHT11 for weather stations, greenhouses and room monitors, and it runs from 3.3 V.
Key specs at a glance
- Humidity
- 0 to 100 % RH, ±2 % typical (±3 % on some grades)
- Temperature
- −40 to 125 °C, ±0.3 °C typical
- Interface
- I2C, address 0x40
- Supply
- 1.5 to 3.6 V chip; modules usually 3.3 V (some accept 5 V)
- Resolution
- 12-bit RH and 14-bit temperature (default)
- Response
- About 5 s for humidity (63 % step)
Models in this guide
These are alternatives. Pick the one that fits your project; you only need one.
Option 1HTU21D Temperature & Humidity Sensor Module – I2C Interface₹155
Option 2Elecrow Crowtail HTU21D Humidity & Temperature Sensor Module – I2C Interface₹569
Option 3TE Connectivity HTU21D HPP845E031R5 Humidity & Temperature Sensor, 0-100% RH, -40°C to 125°C, ±3% RH, I2C DFN₹131
Option 4TE Connectivity HTU21D HPP845E131R1 Humidity & Temperature Sensor, 0–100%RH, −40°C to +125°C, ±3%RH, I2C₹211
Option 5TE Connectivity HTU21D Temperature and Humidity Sensor, 0-100% RH, -40°C to 125°C, I2C Digital, DFN-6 Package₹149
What the HTU21D is
The HTU21D uses a capacitive humidity element and a band-gap temperature sensor, read over I2C. Unlike the DHT sensors, it has no timing-critical one-wire protocol, so it works on any board with I2C.
It shares address 0x40 and most commands with the Si7021, so you cannot put both on the same bus.
HTU21D pinout
The pins on the HTU21D and what each one does.
| Pin | Function |
|---|---|
| VIN / VCC | Supply, 3.3 V (5 V only on modules with a regulator) |
| GND | Ground |
| SDA | I2C data |
| SCL | I2C clock |
- VIN / VCC
- Supply, 3.3 V (5 V only on modules with a regulator)
- GND
- Ground
- SDA
- I2C data
- SCL
- I2C clock
Wiring the HTU21D
Bare HTU21D boards are 3.3 V only. With a 5 V Uno, use a module with a regulator and pull-ups to 3.3 V, or a level shifter.
| HTU21D pin | Arduino Uno | ESP32 |
|---|---|---|
| VCC | 5V (or 3.3V) | 3V3 |
| GND | GND | GND |
| SDA | A4 | GPIO 21 |
| SCL | A5 | GPIO 22 |
- VCC
- Arduino Uno:
- 5V (or 3.3V)
- ESP32:
- 3V3
- GND
- Arduino Uno:
- GND
- ESP32:
- GND
- SDA
- Arduino Uno:
- A4
- ESP32:
- GPIO 21
- SCL
- Arduino Uno:
- A5
- ESP32:
- GPIO 22
Example code
Install "Adafruit HTU21DF Library" from the Library Manager.
#include <Wire.h>
#include "Adafruit_HTU21DF.h"
Adafruit_HTU21DF htu;
void setup() {
Serial.begin(115200);
if (!htu.begin()) { Serial.println("No HTU21D at 0x40"); while (1); }
}
void loop() {
Serial.print(htu.readTemperature()); Serial.print(" C ");
Serial.print(htu.readHumidity()); Serial.println(" %RH");
delay(2000);
}Setup and tuning
mount it in free air, away from the board's regulator and your hand.
in very damp air the reading can stick near 100 %; the chip has a built-in heater to drive off moisture.
in dusty places use a version with a PTFE membrane cover.
What you need
Shop this list8 of 9 found in our store · ₹1,792
HTU21D temperature and humidity module: the sensor this guide coversHTU21D Temperature & Humidity Sensor Module – I2C Interface₹155Closest match, check the specs
Elecrow Crowtail HTU21D Humidity & Temperature Sensor Module – I2C Interface: another version this guide coversElecrow Crowtail HTU21D Humidity & Temperature Sensor Module – I2C Interface₹569
TE Connectivity HTU21D HPP845E031R5 Humidity & Temperature Sensor, 0-100% RH, -40°C to 125°C, ±3% RH, I2C DFN: another version this guide coversTE Connectivity HTU21D HPP845E031R5 Humidity & Temperature Sensor, 0-100% RH, -40°C to 125°C, ±3% RH, I2C DFN₹131
TE Connectivity HTU21D HPP845E131R1 Humidity & Temperature Sensor, 0–100%RH, −40°C to +125°C, ±3%RH, I2C: another version this guide coversTE Connectivity HTU21D HPP845E131R1 Humidity & Temperature Sensor, 0–100%RH, −40°C to +125°C, ±3%RH, I2C₹211
TE Connectivity HTU21D Temperature and Humidity Sensor, 0-100% RH, -40°C to 125°C, I2C Digital, DFN-6 Package: another version this guide coversTE Connectivity HTU21D Temperature and Humidity Sensor, 0-100% RH, -40°C to 125°C, I2C Digital, DFN-6 Package₹149- 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
0.96 inch OLED display 128x64: to show readings without a computer0.96" OLED Display 128x64₹139Closest match, check the specs
Dupont jumper wires: for the connectionsDupont Jumper Wires (40 pcs)₹49Closest match, check the specs
Alternatives and when to choose them
- SHT3x and SHT4x: higher accuracy, multiple addresses.
- AHT20: low-cost I2C alternative.
- DHT11 vs DHT22: simpler single-wire sensors.
Try it: I2c pullup calculator
Change the values and the diagram and results update as you type.
Common mistakes to avoid
- Putting an HTU21D and a Si7021 on the same bus (both use 0x40).
- Powering a bare 3.3 V board from 5 V.
- Mounting it on top of a warm regulator, so temperature reads high and humidity low.
- Reading faster than the sensor can measure.
Frequently asked questions
What is the HTU21D's I2C address?
0x40, fixed.
Is the HTU21D better than a DHT22?
It is digital I2C with better temperature accuracy and no timing-critical protocol.
Can I use two HTU21D sensors?
Not on the same I2C bus; use an I2C multiplexer such as the TCA9548A.
Does it work at 5 V?
Only modules with a regulator; the chip itself is 3.3 V.
Is it the same as the Si7021?
They are close cousins with the same address and similar commands; most libraries read both.
Parts for this guide
- ₹155View
- ₹569View
TE Connectivity HTU21D HPP845E031R5 Humidity & Temperature Sensor, 0-100% RH, -40°C to 125°C, ±3% RH, I2C DFN₹131View
TE Connectivity HTU21D HPP845E131R1 Humidity & Temperature Sensor, 0–100%RH, −40°C to +125°C, ±3%RH, I2C₹211View
TE Connectivity HTU21D Temperature and Humidity Sensor, 0-100% RH, -40°C to 125°C, I2C Digital, DFN-6 Package₹149View- ₹359View
- ₹389View
- ₹139View
- ₹49View
Calculators
Terms in 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.

