---
name: "htu21"
section: "4"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["freebsd"]
url: "https://new.carta.tech/htu21"
---

# htu21(4)

driver for HTU21D and compatible temperature and humidity sensors

## NAME

**htu21** – driver for HTU21D and compatible temperature and humidity sensors

## SYNOPSIS

To compile this driver into the kernel, place the following lines in your kernel configuration file:

**device htu21** **device iicbus**

Alternatively, to load the driver as a module at boot time, place the following line in [loader.conf(5)](/loader.conf/5.md):

```
htu21_load="YES"
```

## DESCRIPTION

The **htu21** driver provides temperature and relative humidity readings over I2C bus for the supported sensors:

- HTU21D

- SHT21

- Si7021

The **htu21** driver reports data via [sysctl(8)](/sysctl/8.md) entries in the device's node in the [sysctl(8)](/sysctl/8.md) tree:

- temperature

  The temperature, in hundredths of Kelvin.

- humidity

  The relative humidity, in hundredths of a percent.

- crc\_errors

  The number of CRC errors in reading the measurements from the device.

- power

  The good power indication. This can be useful with battery powered sensors.

- heater

  The built-in heater control. The heater can be used for testing and for recovery from saturation after high humidity.

- hold\_bus

  Whether the sensor should hold SCL low while performing the measurement. Normally, the sensor releases the bus and NACKs all accessed until the measurement is completed. The hold mode may be useful in mult-master environments.

On an [FDT(4)](/FDT/4.md) based system the following properties must be set:

- *compatible*

  Must be set to "meas,htu21".

- *reg*

  The I2C address of **htu21**. Although, it is hard-wired to 0x40 (7-bit) on all supported sensors.

The DTS part for a **htu21** device usually looks like:

```
/ {
	...
	htu21d {
		compatible = "meas,htu21";
		reg = <0x40>;
	};
};
```

## SEE ALSO

[fdt(4)](/fdt/4.md), [iicbus(4)](/iicbus/4.md), [sysctl(8)](/sysctl/8.md)

## HISTORY

The **htu21** driver and this manual page was written by Andriy Gapon ⟨*avg@FreeBSD.org*⟩.

## BUGS

There is no way to control the measurement resolution.

Some sensor variants do not provide a serial number or use an incompatible format. The **htu21** driver does not distinguish those variants and may complain about incorrect serial number checksum.
