adafruit_sht31d

This is a CircuitPython driver for the SHT31-D temperature and humidity sensor.

  • Author(s): Jerry Needell, Llewelyn Trahaearn

Implementation Notes

Hardware:

Software and Dependencies:

class adafruit_sht31d.SHT31D(i2c_bus: I2C, address: int = 68)[source]

A driver for the SHT31-D temperature and humidity sensor.

Parameters:
  • i2c_bus (I2C) – The I2C bus the SHT31-D is connected to

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

Quickstart: Importing and using the SHT31-D

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

import board
import adafruit_sht31d

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
sht = adafruit_sht31d.SHT31D(i2c)

Now you have access to the temperature and humidity the the temperature and relative_humidity attributes

temperature = sht.temperature
humidity = sht.relative_humidity
property art: bool

Control accelerated response time This feature only affects ‘Periodic’ mode.

property clock_stretching: bool

Control clock stretching. This feature only affects ‘Single’ mode.

property frequency: float

Periodic data acquisition frequency Allowed values are the constants FREQUENCY_* Frequency can not be modified when ART is enabled

property heater: bool

Control device’s internal heater.

property mode: Literal['Single', 'Periodic']

Operation mode Allowed values are the constants MODE_* Return the device to ‘Single’ mode to stop periodic data acquisition and allow it to sleep.

property relative_humidity: float | List[float]

The measured relative humidity in percent. ‘Single’ mode reads and returns the current humidity as a float. ‘Periodic’ mode returns the most recent readings available from the sensor’s cache in a FILO list of eight floats. This list is backfilled with with the sensor’s maximum output of 100.01831417975366 when the sensor is read before the cache is full.

property repeatability: Literal['High', 'Medium', 'Low']

Repeatability Allowed values are the constants REP_*

property serial_number: int

Device serial number.

property status: int

Device status.

property temperature: float | List[float]

The measured temperature in degrees Celsius. ‘Single’ mode reads and returns the current temperature as a float. ‘Periodic’ mode returns the most recent readings available from the sensor’s cache in a FILO list of eight floats. This list is backfilled with with the sensor’s maximum output of 130.0 when the sensor is read before the cache is full.