Same-day dispatch before 2 PM · Free delivery over ₹999 · GST invoices Get the appPrices incl. GST
Geekobot
Snap & SendNEWGeeko AIWhere's myOrder
Log in
Products
  • Projects
    • Component guidesHow parts work, with code you can run
    • Learning pathsFrom your first LED to your first robot
    • Workshops & eventsOnline sessions for makers and classes
    • ElectrolarkFree guided builds, simulator and certificates
    • Students & teachersStudent discount and classroom help
    • CommunityShare builds and ask other makers
    • CalculatorsOhm's law, LED resistor, 555 and 100+ more
    • Circuit builderWire parts and run the circuit, powered by Electrolark
    • Geeko AIAsk what to buy or how to wire it
    • Snap & SendPhotograph a part or list, we find it
    • Part finderAnswer a few questions, get the right part
    • Compatibility checkWill these two parts work together?
    • Compare partsSpecs side by side
    • Business & bulk ordersGST invoices, credit and volume prices
    • Request a quotationSend your list, get a quote
    • Classroom kitsPer-student kits and lab bundles
    • Gift cardsFor students, teams and events
  • Atal Tinkering Lab
BOM to cart
Geekobot

Components, kits and know-how for makers, students, engineers, labs and businesses across India.

Ask Geeko AIOrders, parts and projects, any timeEmail supportReply within 1 working dayGet the Geekobot appAdd it to your home screen, free

Follow us

Shop

  • Boards & SBCs
  • Sensors & Modules
  • IoT & Wireless
  • Drone & FPV
  • 3D Printing
  • Filaments & Resins
  • Motors & Drivers
  • Power & Batteries
  • Semiconductors
  • Passive
  • Displays & LEDs
  • Switches & Relays
  • Wires & Cables
  • Prototyping
  • Tools & Test
  • Robotics
  • STEM Kits
  • Atal Tinkering Lab
  • Mechanical Parts
  • Audio

Orders

  • Track your order
  • Help & support
  • Shipping and delivery
  • Refunds and cancellation
  • Contact us

Learn

  • Projects
  • Geeko AI project assistant
  • Learning paths
  • Guides
  • Calculators
  • Electrolark: free guided builds

Part tools

  • Part finder
  • Compare parts
  • Will it work with my board?

Institutions

  • Classroom kits
  • Atal Tinkering Lab
  • Students & teachers
  • Workshops & Events

Business

  • Business & education
  • Request a quotation
  • BOM bulk upload
  • Quick order by SKU

Company

  • About Geekobot
  • Community
  • Gift cards
  • Terms & conditions
  • Privacy policy
  • Product directory
  • Sitemap

© 2026 Geekobot, a trade name of OLatus Systems Private Limited. All rights reserved.

20, 1st Floor, Neeladri Complex, 10th Cross, Sampige Rd, 2nd Main, Malleshwaram, Bengaluru, Karnataka 560003 · GSTIN 29AACCO0462F1ZM

+91 91810 15607 · connect@geekobot.in · Monday to Saturday, 10 AM to 2 PM IST

UPI · CARDS · NETBANKING · GST INVOICES

ShopProjectsGeeko AIGuides
Compare 0 parts →
Log in

Shop by category

Shop all components
  • Boards & SBCs1,910 products
    • Alternative Single Board Computers
    • Arduino Ecosystem
    • FPGA & Logic Boards
    • Microcontroller & Wireless Boards
    View all
  • Sensors & Modules4,701 products
    • Biomedical & Heart Rate
    • Current, Voltage & Power
    • Force, Weight & Pressure
    • Gas, Weather & Environmental
    View all
  • IoT & Wireless2,314 products
    • RF Modules
    • RFID & NFC
    • Antennas & RF Accessories
    • Cameras & Smart Vision
    View all
  • Drone & FPV3,558 products
    • Flight Control & Navigation
    • FPV Video & Optics
    • Frames & Structural Parts
    • Motors & Propulsion
    View all
  • 3D Printing2,204 products
    • 3D Printers
    • 3D Scanners & Digitizers
    • Laser Engravers & Cutters
    • Material Management & Upgrades
    View all
  • Filaments & Resins1,472 products
    • Filaments
    • Photopolymer Resins
    View all
  • Motors & Drivers463 products
    • BLDC Motor Drivers
    • DC & Geared Motors
    • DC Motor Drivers
    • Linear Actuators & Solenoids
    View all
  • Power & Batteries557 products
    • Battery Holders & Connectors
    • Breadboard Power
    • Chargers & BMS
    • DC-DC Converters
    View all
  • Semiconductors295 products
    • Diodes & Rectifiers
    • Interface & RF Encoder ICs
    • Logic ICs (74xx)
    • Logic ICs (CD4000)
    View all
  • Passive67 products
    • Capacitors
    • Circuit Protection
    • Crystals & Oscillators
    • Inductors
    View all
  • Displays & LEDs572 products
    • 7-Segment & Dot Matrix
    • Addressable LEDs
    • Character LCDs
    • Graphic LCDs
    View all
  • Switches & Relays184 products
    • Keypads & Touch
    • Push Buttons & Tactile
    • Relay Modules
    • Relays
    View all
  • Wires & Cables233 products
    • Board-to-Wire Connectors
    • Crimp & Splice
    • Headers & Dupont
    • Heat Shrink & Sleeving
    View all
  • Prototyping101 products
    • Breadboards
    • Interface Modules
    • PCBs & Perfboards
    View all
  • Tools & Test717 products
    • Bench Power Supplies
    • Hand Tools
    • Measuring Tools
    • Meters & Testers
    View all
  • Robotics180 products
    • Humanoid & Legged Robots
    • Robot Chassis & Platforms
    • Robotic Arms & Grippers
    • Wheels & Casters
    View all
  • STEM Kits268 products
    • Arduino Learning Kits
    • Coding & IoT Kits
    • Early Coding (Ages 3-8)
    • Invention Kits
    View all
  • Atal Tinkering Lab196 products
    • Package 1: Electronics, Robotics, IoT and Sensors
    • Package 2: Rapid Prototyping Tools
    • Package 3: Mechanical, Electrical and Measurement Tools
    • Package 4: Power Supply, Accessories and Safety Equipment
    View all
  • Mechanical Parts212 products
    • Bearings
    • Brackets & Mounts
    • Couplers
    • Fasteners & Standoffs
    View all
  • Audio109 products
    • Amplifier Modules
    • Buzzers & Sirens
    • Speakers
    View all
  1. Home
  2. ›Guides
  3. ›Sensors
  4. ›HTU21D Humidity and Temperature Sensor

Component guide · Beginner · 3 min read

HTU21D Humidity and Temperature Sensor

Pinout, Wiring and Code

By Geekobot Learning Team · Updated 29 Oct 2026

I'm using
Wiring, code and the Run it panels follow your board.
On this page
Short answerWhat the HTU21D isHTU21D pinoutWiring the HTU21DExample codeSetup and tuningWhat you needAlternatives and when to choose themTry itCommon mistakesFAQsParts and next steps
Short answer

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
01

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.

02

HTU21D pinout

The pins on the HTU21D and what each one does.

PinFunction
VIN / VCCSupply, 3.3 V (5 V only on modules with a regulator)
GNDGround
SDAI2C data
SCLI2C clock
PinFunction
VIN / VCC
Supply, 3.3 V (5 V only on modules with a regulator)
GND
Ground
SDA
I2C data
SCL
I2C clock
03

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 pinArduino UnoESP32
VCC5V (or 3.3V)3V3
GNDGNDGND
SDAA4GPIO 21
SCLA5GPIO 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
04

Example code

Install "Adafruit HTU21DF Library" from the Library Manager.

Read temperature and humidity (Adafruit HTU21DF library) · Arduino C++Verify & upload in Electrolark
#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);
}
05

Setup and tuning

Placement

mount it in free air, away from the board's regulator and your hand.

Condensation

in very damp air the reading can stick near 100 %; the chip has a built-in heater to drive off moisture.

Filter

in dusty places use a version with a PTFE membrane cover.

06

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
07

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.
08

Try it: I2c pullup calculator

Change the values and the diagram and results update as you type.

09

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.
10

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

  • HTU21D Temperature & Humidity Sensor Module – I2C Interface
    ₹155View
  • Elecrow Crowtail HTU21D Humidity & Temperature Sensor Module – I2C Interface
    ₹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
  • Uno R3 Development Board (No Cable)
    ₹359View
  • ESP32-WROOM-32 38-Pin Development Board
    ₹389View
  • 0.96" OLED Display 128x64
    ₹139View
  • Dupont Jumper Wires (40 pcs)
    ₹49View
Shop Temperature & Thermal SensorsShop Humidity & Dew Point Sensors

Calculators

I2c pullup calculator

Terms in this guide

I2CInter-Integrated Circuit: a two-wire bus (SDA and SCL) that connects many devices by address.

Keep learning

ComparisonIntermediateSHT3x, SHT4x and Digital Humidity SensorsSensirion SHT3x and SHT4x chips give accurate temperature and relative humidity over I2C and are a big step up from the DHT11.3 min read · SensorsComparisonBeginnerDHT11 vs DHT22DHT11 vs DHT22 compared: accuracy, range and sampling rate, plus wiring, pull-up, Arduino/ESP32 code and when to pick a BME280 or SHT31.3 min read · SensorsHow-toIntermediateWeather Station SensorsA DIY weather station needs three outdoor sensors: an anemometer for wind speed, a wind vane for direction and a tipping-bucket rain gauge.3 min read · SensorsConcept explainerIntermediateI2C ExplainedI2C is a two-wire bus that lets one microcontroller talk to many sensors and displays using a data line (SDA) and a clock line (SCL).4 min read · Electronics Fundamentals

Sources

  • HTU21D(F) digital relative humidity sensor with temperature output datasheet (TE Connectivity)

Written by the Geekobot team from manufacturer datasheets. Always check the datasheet for the exact part and variant you buy.

On this page
Short answerWhat the HTU21D isHTU21D pinoutWiring the HTU21DExample codeSetup and tuningWhat you needAlternatives and when to choose themTry itCommon mistakesFAQsParts and next steps
Need a hand?Ask Geeko AI which part fits your project, or talk to the Geekobot team.Ask Geeko AIHelp & support

Parts for this guide (Arduino Uno)2 items · ₹359

HTU21D Temperature & Humidity Sensor Module – I2C Interface · Uno R3 CH340G ATmega328p Compatible Development Board

Run itChange the inputs and watch the output
Serial monitor115200 baud
26.10 C  54.00 %RH

A simulation of the sketch above, so you know what to expect. Real readings vary with your parts and wiring.

Ask the Community

Ask a question