adafruit_htu31d

Python library for TE HTU31D temperature and humidity sensors

  • Author(s): ladyada, Jose D. Montoya.

Implementation Notes

Hardware:

Software and Dependencies:

class adafruit_htu31d.HTU31D(i2c_bus, address=64)

A driver for the HTU31D temperature and humidity sensor.

Parameters
  • i2c_bus (I2C) – The busio.I2C object to use. This is the only required parameter.

  • address (int) – (optional) The I2C address of the device. Defaults to 0x40

Quickstart: Importing and using the device

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

import board
import adafruit_htu31d

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
htu = adafruit_htu31d.HTU31D(i2c)

Now you have access to the temperature and relative_humidity attributes

temperature = htu.temperature
relative_humidity = htu.relative_humidity
property heater

The current sensor heater mode

property humidity_resolution

The current relative humidity resolution in % rH.

Possibles values:

  • “0.020%”

  • “0.014%”

  • “0.010%”

  • “0.007%”

property measurements

both temperature and relative_humidity, read simultaneously

property relative_humidity

The current relative humidity in % rH

reset()

Perform a soft reset of the sensor, resetting all settings to their power-on defaults

property serial_number

The unique 32-bit serial number

property temp_resolution

The current temperature resolution in Celsius.

Possibles values:

  • “0.040”

  • “0.025”

  • “0.016”

  • “0.012”

property temperature

The current temperature in degrees Celsius