uploaded 8 months ago
I2C driver for HTS221 humidity and temperature sensor


Component: HTS221

I2C driver and definition of HTS221 humidity and temperature sensor.

See HTS221 datasheet.

Operation modes

HTS221 supports autonomous sampling with user defined output data rate, as well as one-shot data acquisition (see hts221_odr_t data type).

New data from HTS221 can be obtained in two modes:

  1. Polling
  2. Data Ready (DRDY) interrupt driven

Note: The user is responsible for initialization and configuration of I2C bus.

Polling mode

After calling hts221_create() and hts221_init() the user is responsible for reading out new samples from HTS221.

If autonomous sampling was configured, it is enough to call hts221_get_temperature() and/or hts221_get_humidity() periodically.

If one-shot sampling was configured, the sampling must be first triggered by hts221_start_oneshot().

Data Ready (DRDY) interrupt driven

In this mode HTS221 asserts DRDY pin when new data of either temperature or humidity is available. The data is read out in a separate FreeRTOS task.

Note: This mode is only available if the DRDY pin of HTS221 is connected to MCU.

After calling hts221_create() and hts221_init(), the DRDY mode is enabled by calling hts221_drdy_enable() which registers a user's new data function callback.


Supports all targets

License: Apache-2.0

To add this component to your project, run: add-dependency "espressif/hts221^1.1.4"

or download archive


  • ESP-IDF >=4.3
  • Stats

    • Downloaded in total
      Downloaded in total 769 times
    • Downloaded this version
      This version: 377 times


    espressif/hts221 version: 1.1.4 |