Helper library for the HTS221 Humidity and Temperature Sensor

  • Author(s): Bryan Siepert

Implementation Notes


Software and Dependencies:
class adafruit_hts221.HTS221(i2c_bus)

Library for the ST HTS221 Humidity and Temperature Sensor


i2c_bus (I2C) – The I2C bus the HTS221 is connected to

Quickstart: Importing and using the HTS221

Here is an example of using the HTS221 class. First you will need to import the libraries to use the sensor

import board
import adafruit_hts221

Once this is done you can define your board.I2C object and define your sensor object

i2c = board.I2C()  # uses board.SCL and board.SDA
hts = adafruit_hts221.HTS221(i2c)

Now you have access to the temperature and relative_humidity attributes

temperature = hts.temperature
relative_humidity = hts.relative_humidity
property data_rate

The rate at which the sensor measures relative_humidity and temperature. data_rate should be set to one of the values of adafruit_hts221.Rate. Note that setting data_rate to Rate.ONE_SHOT will cause relative_humidity and temperature measurements to only update when take_measurements() is called.

property humidity_data_ready

Returns true if a new relative humidity measurement is available to be read

property relative_humidity

The current relative humidity measurement in %rH


Update the value of relative_humidity and temperature by taking a single measurement. Only meaningful if data_rate is set to ONE_SHOT

property temperature

The current temperature measurement in degrees Celsius

property temperature_data_ready

Returns true if a new temperature measurement is available to be read

class adafruit_hts221.Rate

Options for data_rate




Setting data_rate to Rate.ONE_SHOT takes a single humidity and temperature measurement


1 Hz


7 Hz


12.5 Hz