Table of Contents

LamaPLC: HTU TE Connectivity temperature/humidity sensors with I²C communication

HTU21 TE Connectivity temperature/humidity sensors with I²C communication The HTUs are highly accurate, digital relative humidity and temperature sensors known for their low power consumption, I²C interface, and factory calibration.

Key Features

If you'd like to support the development of the site with the price of a coffee — or a few — please do so here.

Here's a handy tip: you can quickly save this page as a PDF by clicking “export to PDF” in the menu on the right side of the screen.

2026/02/14 23:38

Difference between HTU31D, HTU21D and HTU20D

The primary difference among the HTU20D, HTU21D, and HTU31D is an incremental improvement in accuracy, supply-voltage range, and power consumption as the model number increases. The sensors are largely interchangeable and use the same I²C communication protocol.

SpecificationHTU20DHTU21DHTU31D
HTU21
Similar typesSHT20, HTU20, Si702, GY-20 ¹SHT21, HTU21, Si7021, GY-21, GY-213V, HDC1080 ²SHT31, HTU31, Si7031, GY-31 ³
Humidity Accuracy (Typical)±5% RH±2% RH±2% RH
Temperature Accuracy (Typical)Not specified in source±0.3°C±0.2°C
Supply Voltage Range1.5V - 3.6V1.5V - 3.6V3V - 5.5V
Power Consumption (Sleep)Not specified~0.14 µA~0.14 µA (estimated based on similar operation)
InterfaceI²CI²CI²C
Filter OptionHTU20D(F) option availableHTU21D(F) option availableHTU31D(F) option available

¹: The SHT20, HTU20, Si702, GY-20 are different manufacturers' versions of essentially the same I²C digital humidity and temperature sensor chip, designed to be hardware- and software-compatible. The GY-20 is a generic breakout board that uses one of these chips.

²: The SHT21, HTU21, Si7021, GY-21, GY-213V, HDC1080 are very similar digital humidity and temperature sensor chips from different manufacturers (Sensirion, Measurement Specialties, and Silicon Labs, respectively), while the GY-21 is a generic breakout board that uses one of these chips. They are largely interchangeable in hardware and software for most general-purpose applications.

³: The SHT31, HTU31, Si7031, and GY-31 are high-accuracy digital temperature and humidity sensor chips from different manufacturers (Sensirion, TE Connectivity, and Silicon Labs, respectively) that are designed to be largely interchangeable. The GY-31 is a generic name for a breakout board that typically uses the SHT31 chip.

Arduino & HTU31D

To read the HTU31D, the most reliable method is to use the Adafruit HTU31D Library. Compared to the older HTU21D, this sensor handles a wider voltage range (3V–5.5V) and offers even better precision.

Wiring (I²C)

Arduino Example Code

Install the Adafruit HTU31D and Adafruit BusIO libraries via the Arduino Library Manager.

#include <Wire.h>
#include "Adafruit_HTU31D.h"
 
Adafruit_HTU31D htu = Adafruit_HTU31D();
 
void setup() {
  Serial.begin(115200);
  while (!Serial) delay(10);
 
  Serial.println("HTU31D test");
 
  if (!htu.begin(0x40)) { // Use 0x41 if ADR pin is tied to High
    Serial.println("Couldn't find sensor!");
    while (1);
  }
}
 
void loop() {
  sensors_event_t humidity, temp;
 
  // Get both temperature and humidity at once
  htu.getEvent(&humidity, &temp);
 
  Serial.print("Temp: "); 
  Serial.print(temp.temperature); 
  Serial.print(" C \t");
 
  Serial.print("Humidity: "); 
  Serial.print(humidity.relative_humidity); 
  Serial.println(" %");
 
  delay(1000);
}

Advanced Features

The HTU31D includes a built-in heater to dry the sensor if it accumulates condensation. You can toggle it in your code:

Resolution Settings

You can optimize for speed or precision using htu.setResolutions(temp_res, hum_res).

I²C topics on lamaPLC

PageDateTags
2026/04/23 21:51, , , , , , ,
2025/09/23 21:25, , , , , ,
2026/03/22 03:14, , , , , , ,
2026/04/23 21:52, , , , , , , , ,
2026/04/23 21:52, , , , , , , , , , , , ,
2026/03/28 23:50, , , , , , ,
2026/04/12 00:34, , , ,
2026/04/23 21:52, , , , , , , , , , , , , ,
2026/04/23 21:52, , , , , , , , , , ,
2026/04/23 21:52, , , , , , , , , ,
2026/03/22 00:08, , , , , , , , , , ,
2026/04/23 21:52, , , , , , , , , , ,
2026/04/23 21:52, , , , , , , ,
2025/05/31 23:32, , , , , , , ,
2026/04/23 21:52, , , , , , , , , , , , , ,
2025/11/22 00:07, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
2023/07/01 17:29, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
2026/03/22 01:44, , , , , , , , ,
2026/04/23 21:52, , , , , , , , ,
2026/04/23 21:52, , , , , , , , , , , , , , , ,
2026/04/23 21:51, , , ,
2026/04/23 21:52, , , , , , , , , , , , , , , , , , , , , , , , ,
2026/04/11 19:54, , , , , , , , , , , , , , , , , , ,
2026/04/23 21:52, , , , , , , , , , ,
2026/02/14 18:27, , , , , , , , , ,
2026/04/23 21:52, , , , , , ,
2026/04/23 21:52, , , , , , , ,
2026/04/23 21:52, , , , , , , ,
2026/04/23 21:52, , , , , , , , , , , , ,
2026/04/15 19:41, , , , , , , , , , , , , , , ,
2026/04/23 21:52, , , , , , , , , , , , , ,
2026/02/14 23:47, , , ,
2026/02/14 23:51, , , , , ,
2026/02/14 18:26, , , ,
2026/04/23 21:52, , , , , , , , , , , , ,
2026/04/23 21:52, , , , , , , , , , ,
2026/04/23 21:52, , , , , , , ,
2026/03/05 21:19, , , , , , , , , , , , , , , , ,
2026/02/14 18:27, , , , , , ,



This page has been accessed for: Today: 2, Until now: 4