API Reference

SHT3x

Sht3xI2cDevice

class sensirion_i2c_sht.sht3x.device.Sht3xI2cDevice(connection, slave_address=68)[source]

SHT3x I²C device class to allow executing I²C commands.

__init__(connection, slave_address=68)[source]

Constructs a new SHT3x I²C device.

Parameters:
  • connection (I2cConnection) – The I²C connection to use for communication.
  • slave_address (byte) – The I²C slave address, defaults to 0x44.
single_shot_measurement(repeatability=<Sht3xRepeatability.HIGH: 1>)[source]

Trigger a measurement and read the temperature and humidity.

Parameters:repeatability (Sht3xRepeatability) – Configure the repeatability setting.
Raises:ValueError – If the passed repeatability is not valid.
Returns:The measured temperature and humidity.
Return type:tuple
art_enable()[source]

Enable the ART (accelerated response time

heater_on()[source]

Switch on the internal heater.

heater_off()[source]

Switch off the internal heater.

read_status_register()[source]

Read out the status register.

Returns:The status register.
Return type:Sht3xStatusRegister
clear_status_register()[source]

Clear the status register. All flags (Bit 15, 11, 10, 4) in the status register can be cleared (set to zero).

soft_reset()[source]

Perform a soft reset for the device. This can be used to force the system into a well-defined state without removing the power supply.

read_serial_number()[source]

Read the serial number from the device.

Returns:The serial number.
Return type:int
connection

Get the used I²C connection.

Returns:The used I²C connection.
Return type:I2cConnection
execute(command)

Execute an I²C command on this device.

Parameters:command (I2cCommand) – The command to be executed.
Returns:The interpreted response of the executed command.
Return type:Depends on the executed command.
slave_address

Get the I²C slave address.

Returns:The I²C slave address.
Return type:byte

Sht3xI2cCommand

class sensirion_i2c_sht.sht3x.commands.Sht3xI2cCmdBase(command, tx_data, rx_length, read_delay, timeout, post_processing_time=0.0)[source]

SHT3x I²C base command.

__init__(command, tx_data, rx_length, read_delay, timeout, post_processing_time=0.0)[source]

Constructs a new SHT3x I²C command.

Parameters:
  • command (int/None) – The command ID to be sent to the device. None means that no command will be sent, i.e. only tx_data (if not None) will be sent. No CRC is added to these bytes since the command ID usually already contains a CRC.
  • tx_data (bytes-like/list/None) – Bytes to be extended with CRCs and then sent to the I²C device. None means that no write header will be sent at all (if command is None too). An empty list means to send the write header (even if command is None), but without data following it.
  • rx_length (int/None) – Number of bytes to be read from the I²C device, including CRC bytes. None means that no read header is sent at all. Zero means to send the read header, but without reading any data.
  • read_delay (float) – Delay (in Seconds) to be inserted between the end of the write operation and the beginning of the read operation. This is needed if the device needs some time to prepare the RX data, e.g. if it has to perform a measurement. Set to 0.0 to indicate that no delay is needed, i.e. the device does not need any processing time.
  • timeout (float) – Timeout (in Seconds) to be used in case of clock stretching. If the device stretches the clock longer than this value, the transceive operation will be aborted with a timeout error. Set to 0.0 to indicate that the device will not stretch the clock for this command.
  • post_processing_time (float) – Maximum time in seconds the device needs for post processing of this command until it is ready to receive the next command. For example after a device reset command, the device might need some time until it is ready again. Usually this is 0.0s, i.e. no post processing is needed.
interpret_response(data)

Validates the CRCs of the received data from the device and returns the data with all CRCs removed.

Parameters:data (bytes) – Received raw bytes from the read operation.
Returns:The received bytes, or None if there is no data received.
Return type:bytes or None
Raises:I2cChecksumError – If a received CRC was wrong.
class sensirion_i2c_sht.sht3x.commands.Sht3xI2cCmdMeasBase(command, read_delay)[source]

Base SHT3x command for a single shot measurement with clock stretching disabled.

__init__(command, read_delay)[source]

Constructs a new command.

Parameters:
  • command (int/None) – The command word to be sent to the device. None means that no command will be sent, i.e. only tx_words (if not None) will be sent.
  • read_delay (float) – Delay (in Seconds) to be inserted between the end of the write operation and the beginning of the read operation. This is needed if the device needs some time to prepare the RX data, e.g. if it has to perform a measurement. Set to 0.0 to indicate that no delay is needed, i.e. the device does not need any processing time.
interpret_response(data)[source]

Converts the raw response from the device to the proper data type.

Parameters:data (bytes) – Received raw bytes from the read operation.
Returns:The measured temperature and humidity.
Return type:tuple
class sensirion_i2c_sht.sht3x.commands.Sht3xI2cCmdMeasHighRes[source]

SHT3x command for a single shot measurement with high repeatability and clock stretching disabled.

__init__()[source]

Constructs a new command.

interpret_response(data)

Converts the raw response from the device to the proper data type.

Parameters:data (bytes) – Received raw bytes from the read operation.
Returns:The measured temperature and humidity.
Return type:tuple
class sensirion_i2c_sht.sht3x.commands.Sht3xI2cCmdMeasMediumRes[source]

SHT3x command for a single shot measurement with medium repeatability and clock stretching disabled.

__init__()[source]

Constructs a new command.

interpret_response(data)

Converts the raw response from the device to the proper data type.

Parameters:data (bytes) – Received raw bytes from the read operation.
Returns:The measured temperature and humidity.
Return type:tuple
class sensirion_i2c_sht.sht3x.commands.Sht3xI2cCmdMeasLowRes[source]

SHT3x command for a single shot measurement with low repeatability and clock stretching disabled.

__init__()[source]

Constructs a new command.

interpret_response(data)

Converts the raw response from the device to the proper data type.

Parameters:data (bytes) – Received raw bytes from the read operation.
Returns:The measured temperature and humidity.
Return type:tuple
class sensirion_i2c_sht.sht3x.commands.Sht3xI2cCmdEnableART[source]

SHT3x command to enable the ART (accelerated response time) feature.

__init__()[source]

Constructs a new command.

interpret_response(data)

Validates the CRCs of the received data from the device and returns the data with all CRCs removed.

Parameters:data (bytes) – Received raw bytes from the read operation.
Returns:The received bytes, or None if there is no data received.
Return type:bytes or None
Raises:I2cChecksumError – If a received CRC was wrong.
class sensirion_i2c_sht.sht3x.commands.Sht3xI2cCmdHeaterOn[source]

SHT3x command to enable the internal heater.

__init__()[source]

Constructs a new command.

interpret_response(data)

Validates the CRCs of the received data from the device and returns the data with all CRCs removed.

Parameters:data (bytes) – Received raw bytes from the read operation.
Returns:The received bytes, or None if there is no data received.
Return type:bytes or None
Raises:I2cChecksumError – If a received CRC was wrong.
class sensirion_i2c_sht.sht3x.commands.Sht3xI2cCmdHeaterOff[source]

SHT3x command to disable the internal heater.

__init__()[source]

Constructs a new command.

interpret_response(data)

Validates the CRCs of the received data from the device and returns the data with all CRCs removed.

Parameters:data (bytes) – Received raw bytes from the read operation.
Returns:The received bytes, or None if there is no data received.
Return type:bytes or None
Raises:I2cChecksumError – If a received CRC was wrong.
class sensirion_i2c_sht.sht3x.commands.Sht3xI2cCmdSoftReset[source]

SHT3x command for a soft reset.

__init__()[source]

Constructs a new command.

interpret_response(data)

Validates the CRCs of the received data from the device and returns the data with all CRCs removed.

Parameters:data (bytes) – Received raw bytes from the read operation.
Returns:The received bytes, or None if there is no data received.
Return type:bytes or None
Raises:I2cChecksumError – If a received CRC was wrong.
class sensirion_i2c_sht.sht3x.commands.Sht3xI2cCmdReadStatusRegister[source]

SHT3x command to read the status register.

__init__()[source]

Constructs a new command.

interpret_response(data)[source]

Converts the raw response from the device to the proper data type.

Parameters:data (bytes) – Received raw bytes from the read operation.
Returns:The status register.
Return type:Sht3xStatusRegister
class sensirion_i2c_sht.sht3x.commands.Sht3xI2cCmdResetStatusRegister[source]

SHT3x command to reset the status register.

__init__()[source]

Constructs a new command.

interpret_response(data)

Validates the CRCs of the received data from the device and returns the data with all CRCs removed.

Parameters:data (bytes) – Received raw bytes from the read operation.
Returns:The received bytes, or None if there is no data received.
Return type:bytes or None
Raises:I2cChecksumError – If a received CRC was wrong.
class sensirion_i2c_sht.sht3x.commands.Sht3xI2cCmdReadSerial[source]

SHT3x command to read the serial number.

__init__()[source]

Constructs a new command.

interpret_response(data)[source]

Converts the raw response from the device to the proper data type.

Parameters:data (bytes) – Received raw bytes from the read operation.
Returns:The serial number.
Return type:int

Data Types

class sensirion_i2c_sht.sht3x.data_types.Sht3xRepeatability[source]

An enum containing all available repeatability settings for the temperature and humidity measurement.

HIGH = 1

High repeatability

MEDIUM = 2

Medium repeatability

LOW = 3

Low repeatability

Response Types

class sensirion_i2c_sht.sht3x.response_types.Sht3xTemperature(ticks)[source]

Represents a measurement response for the temperature.

With the ticks you can access the raw data as received from the device. For the converted values you can choose between degrees_celsius and degrees_fahrenheit.

Parameters:ticks (int) – The read ticks as received from the device.
__init__(ticks)[source]

Creates an instance from the received raw data.

ticks

The ticks (int) as received from the device.

degrees_celsius

The converted temperature in °C.

degrees_fahrenheit

The converted temperature in °F.

class sensirion_i2c_sht.sht3x.response_types.Sht3xHumidity(ticks)[source]

Represents a measurement response for the humidity.

With the ticks you can access the raw data as received from the device. For the converted value the percent_rh attribute is available.

Parameters:ticks (int) – The read ticks as received from the device.
__init__(ticks)[source]

Creates an instance from the received raw data.

ticks

The ticks (int) as received from the device.

percent_rh

The converted humidity in %RH.

class sensirion_i2c_sht.sht3x.response_types.Sht3xStatusRegister(raw)[source]

Represents the content of the status register.

With the status_register_word you can access the raw data as received from the device. For each data field of the status register an attribute is available.

Parameters:raw (int) – The read status register word as received from the device.
__init__(raw)[source]

Creates an instance from the received raw data.

raw

The raw data word (int) as received from the device.

write_data_checksum_status

Write data checksum status (Bit 0, bool)

  • False: checksum of last write transfer was correct
  • True: checksum of last write transfer failed
command_status

Command status (Bit 1, bool)

  • False: last command executed successfully
  • True: last command not processed. It was either invalid or failed the integrated command checksum
temperature_tracking_alert

Temperature tracking alert (Bit 10, bool)

  • False: no alert
  • True: alert
humidity_tracking_alert

Humidity tracking alert (Bit 11, bool)

  • False: no alert
  • True: alert
heater_status

Heater status (Bit 13, bool)

  • False: heater off
  • True: heater on
alert_pending_status

Alert pending status (Bit 15, bool)

  • False: no pending alerts
  • True: at least one pending alert