
Adafruit HTU21D-F Temperature & Humidity Sensor
Created by lady ada
Last updated on 2021-04-14 05:22:35 PM EDT

2
3
6
7
7
8
8
8
9
10
10
11
12
13
13
14
15
16
16
17
18
19
19
19
20
Guide Contents
Guide Contents
Overview
Pinouts
Power Pins:
I2C Logic pins:
Assembly
Prepare the header strip:
Add the breakout board:
And Solder!
Wiring & Test
Download Adafruit_HTU21DF
Load Demo
Library Reference
Python & CircuitPython
CircuitPython MicroController Wiring
Python Computer Wiring
CircuitPython Installation of HTU21D Library
Python Installation of HTU21D Library
CircuitPython & Python Usage
Full Example Code
Python Docs
Downloads
Files & Datasheets
Schematic and Fab Print for STEMMA QT Version
Schematic and Fab Print for Original Version
© Adafruit Industries https://learn.adafruit.com/adafruit-htu21d-f-temperature-humidity-sensor Page 2 of 22

Overview
It's summer and you're sweating and your hair's all frizzy and all you really want to know is why the
weatherman said this morning that today's relative humidity would max out at a perfectly reasonable 52%
when it feels more like 77%. Enter the HTU21D-F Temperature + Humidity Sensor - the best way to prove
the weatherman wrong!
This I2C digital humidity sensor is an accurate and intelligent alternative to the much simpler Humidity and
Temperature Sensor - SHT15 Breakout (http://adafru.it/1638) It has a typical accuracy of ±2% with an
operating range that's optimized from 5% to 95% RH. Operation outside this range is still possible - just
the accuracy might drop a bit. The temperature output has an accuracy of ±1°C from -30~90°C. If you're
© Adafruit Industries https://learn.adafruit.com/adafruit-htu21d-f-temperature-humidity-sensor Page 3 of 22

looking to measure temperature more accurately, we recommend the MCP9808 High Accuracy I2C
Temperature Sensor Breakout Board. (http://adafru.it/1782)
Such a lovely chip - so we spun up a breakout board that includes the Filtered version (the white bit of
plastic which is a PTFE filter to keep the sensor clean), a 3.3V regulator and I2C level shifting circuitry. This
lets you use it safely with any kind of microcontroller with 3.3V-5V power or logic.
To get you going fast, we spun up a custom made PCB in the STEMMA QT form
factor (https://adafru.it/LBQ), making them easy to interface with. The STEMMA QT
connectors (https://adafru.it/JqB) on either side are compatible with the SparkFun
Qwiic (https://adafru.it/Fpw) I2C connectors. This allows you to make solderless connections between
© Adafruit Industries https://learn.adafruit.com/adafruit-htu21d-f-temperature-humidity-sensor Page 4 of 22

your development board and the HTU21Ds or to chain them with a wide range of other sensors and
accessories using a compatible cable (https://adafru.it/JnB). QT Cable is not included, but we have a
variety in the shop (https://adafru.it/JnB).
Each order comes with one fully assembled and tested PCB breakout and a small piece of header. You'll
need to solder the header onto the PCB but it's fairly easy and takes only a few minutes even for a
beginner.
There are two versions of this board - the STEMMA QT version shown above, and the original
header-only version shown below. Code works the same on both!
© Adafruit Industries https://learn.adafruit.com/adafruit-htu21d-f-temperature-humidity-sensor Page 5 of 22

Pinouts
The HTU21D-F is a I2C sensor. That means it uses the two I2C data/clock wires available on most
microcontrollers, and can share those pins with other sensors as long as they don't have an address
collision. For future reference, the I2C address is 0x40 and you
can't
change it!
© Adafruit Industries https://learn.adafruit.com/adafruit-htu21d-f-temperature-humidity-sensor Page 6 of 22

Power Pins:
Vin - this is the power pin. Since the chip uses 3 VDC, we have included a voltage regulator on board
that will take 3-5VDC and safely convert it down. To power the board, give it the same power as the
logic level of your microcontroller - e.g. for a 5V micro like Arduino, use 5V
3Vo (3v3 on original version) - this is the 3.3V output from the voltage regulator, you can grab up to
100mA from this if you like
GND - common ground for power and logic
I2C Logic pins:
SCL - I2C clock pin, connect to your microcontrollers I2C clock line.
SDA - I2C data pin, connect to your microcontrollers I2C data line.
STEMMA QT (https://adafru.it/Ft4) - These connectors allow you to connect to development boards
with STEMMA QT connectors, or to other things, with various associated
accessories (https://adafru.it/Ft6).
© Adafruit Industries https://learn.adafruit.com/adafruit-htu21d-f-temperature-humidity-sensor Page 7 of 22