adafruit_sht4x

Python library for Sensirion SHT4x temperature and humidity sensors

  • Author(s): ladyada

Implementation Notes

Hardware:

Software and Dependencies:

class adafruit_sht4x.CV

struct helper

classmethod add_values(value_tuples: Tuple[str, int, str, float]) None

Add CV values to the class

classmethod is_valid(value: int) bool

Validate that a given value is a member

class adafruit_sht4x.Mode

Options for power_mode

class adafruit_sht4x.SHT4x(i2c_bus: I2C, address: int = 68)

A driver for the SHT4x temperature and humidity sensor.

Parameters:
  • i2c_bus (I2C) – The I2C bus the SHT4x is connected to.

  • address (int) – The I2C device address. Default is 0x44

Quickstart: Importing and using the SHT4x temperature and humidity sensor

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

import board
import adafruit_sht4x

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_sht4x.SHT4x(i2c)

You can now make some initial settings on the sensor

sht.mode = adafruit_sht4x.Mode.NOHEAT_HIGHPRECISION

Now you have access to the temperature and humidity using the measurements. It will return a tuple with the temperature and relative_humidity measurements

temperature, relative_humidity = sht.measurements
property measurements: Tuple[float, float]

both temperature and relative_humidity, read simultaneously

property mode: int

The current sensor reading mode (heater and precision)

property relative_humidity: float

The current relative humidity in % rH. This is a value from 0-100%.

reset() None

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

property serial_number: int

The unique 32-bit serial number

property temperature: float

The current temperature in degrees Celsius