API Reference
SHT2x
Sht2xI2cDevice
- class sensirion_i2c_sht.sht2x.device.Sht2xI2cDevice(connection, slave_address=64)[source]
SHT2x I²C device class to allow executing I²C commands.
- __init__(connection, slave_address=64)[source]
Constructs a new SHT2x 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()[source]
Trigger a measurement and read the temperature and humidity.
- Returns:
The measured temperature and humidity.
temperature (
Sht2xTemperature) - Temperature response object.humidity (
Sht2xHumidity) - Humidity response object.
- Return type:
tuple
Sht2xI2cCommand
- class sensirion_i2c_sht.sht2x.commands.Sht2xI2cCmdBase(command, tx_data, rx_length, read_delay, timeout, command_bytes=1, post_processing_time=0.0)[source]
Sht2x I²C base command.
- __init__(command, tx_data, rx_length, read_delay, timeout, command_bytes=1, post_processing_time=0.0)[source]
Constructs a new SHT2x 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
commandis None too). An empty list means to send the write header (even ifcommandis 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.
command_bytes (int) – Number of command bytes.
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.
- class sensirion_i2c_sht.sht2x.commands.Sht2xI2cMeasureHumidity[source]
Sht2x command for a single shot measurement with clock stretching disabled.
- class sensirion_i2c_sht.sht2x.commands.Sht2xI2cMeasureTemperature[source]
Sht2x command for a single shot measurement with clock stretching disabled.
- class sensirion_i2c_sht.sht2x.commands.Sht2xI2cCmdSoftReset[source]
Sht2x command for a soft reset.
- class sensirion_i2c_sht.sht2x.commands.Sht2xI2cCmdReadOtp(address, number_of_bytes_to_read)[source]
Sht2x command to read from the OTP.
Response Types
- class sensirion_i2c_sht.sht2x.response_types.Sht2xTemperature(ticks)[source]
Represents a measurement response for the temperature.
With the
ticksyou can access the raw data as received from the device. For the converted values you can choose betweendegrees_celsiusanddegrees_fahrenheit.- Parameters:
ticks (int) – The read ticks as received from the device.
- 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.sht2x.response_types.Sht2xHumidity(ticks)[source]
Represents a measurement response for the humidity.
With the
ticksyou can access the raw data as received from the device. For the converted value thepercent_rhattribute is available.- Parameters:
ticks (int) – The read ticks as received from the device.
- ticks
The ticks (int) as received from the device.
- percent_rh
The converted humidity in %RH.
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)[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.
temperature (
Sht3xTemperature) - Temperature response object.humidity (
Sht3xHumidity) - Humidity response object.
- Return type:
tuple
- read_status_register()[source]
Read out the status register.
- Returns:
The status register.
- Return type:
- 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).
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
commandis None too). An empty list means to send the write header (even ifcommandis 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.
- 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.
temperature (
Sht3xTemperature) - Temperature response object.humidity (
Sht3xHumidity) - Humidity response object.
- 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.
- class sensirion_i2c_sht.sht3x.commands.Sht3xI2cCmdMeasMediumRes[source]
SHT3x command for a single shot measurement with medium repeatability and clock stretching disabled.
- class sensirion_i2c_sht.sht3x.commands.Sht3xI2cCmdMeasLowRes[source]
SHT3x command for a single shot measurement with low repeatability and clock stretching disabled.
- class sensirion_i2c_sht.sht3x.commands.Sht3xI2cCmdEnableART[source]
SHT3x command to enable the ART (accelerated response time) feature.
- class sensirion_i2c_sht.sht3x.commands.Sht3xI2cCmdHeaterOn[source]
SHT3x command to enable the internal heater.
- class sensirion_i2c_sht.sht3x.commands.Sht3xI2cCmdHeaterOff[source]
SHT3x command to disable the internal heater.
- class sensirion_i2c_sht.sht3x.commands.Sht3xI2cCmdSoftReset[source]
SHT3x command for a soft reset.
- class sensirion_i2c_sht.sht3x.commands.Sht3xI2cCmdReadStatusRegister[source]
SHT3x command to read the status register.
- class sensirion_i2c_sht.sht3x.commands.Sht3xI2cCmdResetStatusRegister[source]
SHT3x command to reset the status register.
Data Types
Response Types
- class sensirion_i2c_sht.sht3x.response_types.Sht3xTemperature(ticks)[source]
Represents a measurement response for the temperature.
With the
ticksyou can access the raw data as received from the device. For the converted values you can choose betweendegrees_celsiusanddegrees_fahrenheit.- Parameters:
ticks (int) – The read ticks as received from the device.
- 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
ticksyou can access the raw data as received from the device. For the converted value thepercent_rhattribute is available.- Parameters:
ticks (int) – The read ticks as received from the device.
- 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_wordyou 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.
- 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
SHTC3
Shtc3I2cDevice
- class sensirion_i2c_sht.shtc3.device.Shtc3I2cDevice(connection, slave_address=112)[source]
SHTC3 I²C device class to allow executing I²C commands.
- __init__(connection, slave_address=112)[source]
Constructs a new SHTC3 I²C device.
- Parameters:
connection (I2cConnection) – The I²C connection to use for communication.
slave_address (byte) – The I²C slave address, defaults to 0x70.
- measure(power_mode=Shtc3PowerMode.NORMAL)[source]
Trigger a measurement with clock stretching disabled and read the temperature and humidity.
- Parameters:
power_mode (Shtc3PowerMode) – Configure the power mode setting.
- Raises:
ValueError – If the passed power mode is not valid.
- Returns:
The measured temperature and humidity.
temperature (
Shtc3xTemperature) - Temperature response object.humidity (
Shtc3Humidity) - Humidity response object.
- Return type:
tuple
- measure_clock_stretching(power_mode=Shtc3PowerMode.NORMAL)[source]
Trigger a measurement with clock stretching enabled and read the temperature and humidity.
- Parameters:
power_mode (Shtc3PowerMode) – Configure the power mode setting.
- Raises:
ValueError – If the passed power mode is not valid.
- Returns:
The measured temperature and humidity.
temperature (
Shtc3xTemperature) - Temperature response object.humidity (
Shtc3Humidity) - Humidity response object.
- Return type:
tuple
- read_product_id()[source]
Read the product id from the device.
- Returns:
The product id.
- Return type:
int
- wake_up()[source]
wake up SHTC3.
Note
When the sensor is in sleep mode, it requires the wake-up command before any further communication
Shtc3I2cCommand
- class sensirion_i2c_sht.shtc3.commands.Shtc3I2cCmdBase(command, tx_data, rx_length, read_delay, timeout, post_processing_time=0.0)[source]
shtc3 I²C base command.
- __init__(command, tx_data, rx_length, read_delay, timeout, post_processing_time=0.0)[source]
Constructs a new shtc3 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
commandis None too). An empty list means to send the write header (even ifcommandis 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.
- class sensirion_i2c_sht.shtc3.commands.Shtc3I2cCmdMeasureNormalModeTicksClockStretching[source]
Measure Normal Mode Ticks Clock Stretching I²C Command
Measure in normal mode with clock stretching enabled.
- interpret_response(data)[source]
Validates the CRCs of the received data from the device and returns the interpreted data.
- Parameters:
data (bytes) – Received raw bytes from the read operation.
- Returns:
temperature (
Shtc3xTemperature) - Temperature response object.humidity (
Shtc3Humidity) - Humidity response object.
- Return type:
tuple
- Raises:
I2cChecksumError – If a received CRC was wrong.
- class sensirion_i2c_sht.shtc3.commands.Shtc3I2cCmdMeasureLowestPowerModeTicksClockStretching[source]
Measure Lowest Power Mode Ticks Clock Stretching I²C Command
Measure in low power mode with clock stretching enabled.
- interpret_response(data)[source]
Validates the CRCs of the received data from the device and returns the interpreted data.
- Parameters:
data (bytes) – Received raw bytes from the read operation.
- Returns:
temperature (
Shtc3xTemperature) - Temperature response object.humidity (
Shtc3Humidity) - Humidity response object.
- Return type:
tuple
- Raises:
I2cChecksumError – If a received CRC was wrong.
- class sensirion_i2c_sht.shtc3.commands.Shtc3I2cCmdMeasureNormalModeTicks[source]
Measure Normal Mode Ticks I²C Command
Measure in normal mode with clock stretching disabled.
- interpret_response(data)[source]
Validates the CRCs of the received data from the device and returns the interpreted data.
- Parameters:
data (bytes) – Received raw bytes from the read operation.
- Returns:
temperature (
Shtc3xTemperature) - Temperature response object.humidity (
Shtc3Humidity) - Humidity response object.
- Return type:
tuple
- Raises:
I2cChecksumError – If a received CRC was wrong.
- class sensirion_i2c_sht.shtc3.commands.Shtc3I2cCmdMeasureLowestPowerModeTicks[source]
Measure Lowest Power Mode Ticks I²C Command
Measure in low power mode with clock stretching disabled.
- interpret_response(data)[source]
Validates the CRCs of the received data from the device and returns the interpreted data.
- Parameters:
data (bytes) – Received raw bytes from the read operation.
- Returns:
temperature (
Shtc3xTemperature) - Temperature response object.humidity (
Shtc3Humidity) - Humidity response object.
- Return type:
tuple
- Raises:
I2cChecksumError – If a received CRC was wrong.
- class sensirion_i2c_sht.shtc3.commands.Shtc3I2cCmdProductId[source]
Product Id I²C Command
Read out the product id.
Note
The SHTC3 has an ID register which contains an SHTC3- specific product code. The read-out of the ID register can be used to verify the presence of the sensor and proper communication.
- interpret_response(data)[source]
Validates the CRCs of the received data from the device and returns the interpreted data.
- Parameters:
data (bytes) – Received raw bytes from the read operation.
- Returns:
SHTC3-specific product code
- Return type:
int
- Raises:
I2cChecksumError – If a received CRC was wrong.
- class sensirion_i2c_sht.shtc3.commands.Shtc3I2cCmdSoftReset[source]
Soft Reset I²C Command
Perform a soft reset. reset all internal state machines and reload calibration data from the memory.
Note
A reset of the sensor can be achieved in three ways: • Soft reset: use this function • I2C general call: all devices on the I2C bus are reset by sending the command 0x06 to the I2C address 0x00. • Power down (incl.pulling SCL and SDA low)
- class sensirion_i2c_sht.shtc3.commands.Shtc3I2cCmdWakeUp[source]
Wake Up I²C Command
Wake-up command of the sensor.
Note
When the sensor is in sleep mode, it requires the wake-up command before any further communication
Data Types
Response Types
- class sensirion_i2c_sht.shtc3.response_types.Shtc3Temperature(ticks)[source]
Represents a measurement response for the temperature.
With the
ticksyou can access the raw data as received from the device. For the converted values you can choose betweendegrees_celsiusanddegrees_fahrenheit.- Parameters:
ticks (int) – The read ticks as received from the device.
- 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.shtc3.response_types.Shtc3Humidity(ticks)[source]
Represents a measurement response for the humidity.
With the
ticksyou can access the raw data as received from the device. For the converted value thepercent_rhattribute is available.- Parameters:
ticks (int) – The read ticks as received from the device.
- ticks
The ticks (int) as received from the device.
- percent_rh
The converted humidity in %RH.
SHT4x
Sht4xI2cDevice
- class sensirion_i2c_sht.sht4x.device.Sht4xI2cDevice(connection, slave_address=68)[source]
SHT4x I²C device class to allow executing I²C commands.
- __init__(connection, slave_address=68)[source]
Constructs a new SHT4x 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=Sht4xRepeatability.HIGH)[source]
Trigger a measurement and read the temperature and humidity.
- Parameters:
repeatability (Sht4xRepeatability) – Configure the repeatability setting.
- Raises:
ValueError – If the passed repeatability is not valid.
- Returns:
The measured temperature and humidity.
temperature (
Sht4xTemperature) - Temperature response object.humidity (
Sht4xHumidity) - Humidity response object.
- Return type:
tuple
- activate_heater(power=Sht4xHeaterPower.HIGH, duration=Sht4xHeaterActivationDuration.LONG)[source]
Activate the heater and trigger a high precision measurement.
Important notes for operating the heater:
The heater is designed for a maximum duty cycle of 5%.
During operation of the heater, sensor specifications are not valid.
The temperature sensor can additionally be affected by the thermally induced mechanical stress, offsetting the temperature reading from the actual temperature.
The sensor’s temperature (base temperature + temperature increase from heater) must not exceed Tmax = 125 °C in order to have proper electrical functionality of the chip.
If higher heating temperatures are desired, consecutive heating commands have to be sent to the sensor. The heater shall only be operated in ambient temperatures below 65°C else it could drive the sensor outside of its maximal operating temperature.
- Parameters:
power (Sht4xHeaterPower) – Configure the heater power setting.
duration (Sht4xHeaterActivationDuration) – Configure the heater activation duration.
- Raises:
ValueError – If the passed parameters are not valid.
- Returns:
The measured temperature and humidity.
temperature (
Sht4xTemperature) - Temperature response object.humidity (
Sht4xHumidity) - Humidity response object.
- Return type:
tuple
Sht4xI2cCommand
- class sensirion_i2c_sht.sht4x.commands.Sht4xI2cCmdBase(command, tx_data, rx_length, read_delay, post_processing_time=0.0)[source]
SHT4x I²C base command.
- __init__(command, tx_data, rx_length, read_delay, post_processing_time=0.0)[source]
Constructs a new SHT4x 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
commandis None too). An empty list means to send the write header (even ifcommandis 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.
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.
- class sensirion_i2c_sht.sht4x.commands.Sht4xI2cCmdMeasBase(command, read_delay)[source]
Base SHT4x command for a single shot measurement.
- __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.
temperature (
Sht4xTemperature) - Temperature response object.humidity (
Sht4xHumidity) - Humidity response object.
- Return type:
tuple
- class sensirion_i2c_sht.sht4x.commands.Sht4xI2cCmdMeasHighRes[source]
SHT4x command for a single shot measurement with high repeatability.
- class sensirion_i2c_sht.sht4x.commands.Sht4xI2cCmdMeasMediumRes[source]
SHT4x command for a single shot measurement with medium repeatability.
- class sensirion_i2c_sht.sht4x.commands.Sht4xI2cCmdMeasLowRes[source]
SHT4x command for a single shot measurement with low repeatability.
- class sensirion_i2c_sht.sht4x.commands.Sht4xI2cCmdHeaterHighPowerLong[source]
SHT4x command activate highest heater power and a high precision measurement (typ. 200mW @ 3.3V) for 1 second.
- class sensirion_i2c_sht.sht4x.commands.Sht4xI2cCmdHeaterHighPowerShort[source]
SHT4x command activate highest heater power and a high precision measurement (typ. 200mW @ 3.3V) for 0.1 second.
- class sensirion_i2c_sht.sht4x.commands.Sht4xI2cCmdHeaterMediumPowerLong[source]
SHT4x command activate medium heater power and a high precision measurement (typ. 110mW @ 3.3V) for 1 second.
- class sensirion_i2c_sht.sht4x.commands.Sht4xI2cCmdHeaterMediumPowerShort[source]
SHT4x command activate medium heater power and a high precision measurement (typ. 110mW @ 3.3V) for 0.1 second.
- class sensirion_i2c_sht.sht4x.commands.Sht4xI2cCmdHeaterLowPowerLong[source]
SHT4x command activate lowest heater power and a high precision measurement (typ. 20mW @ 3.3V) for 1 second.
- class sensirion_i2c_sht.sht4x.commands.Sht4xI2cCmdHeaterLowPowerShort[source]
SHT4x command activate lowest heater power and a high precision measurement (typ. 20mW @ 3.3V) for 0.1 second.
- class sensirion_i2c_sht.sht4x.commands.Sht4xI2cCmdSoftReset[source]
SHT4x command for a soft reset.
Data Types
- class sensirion_i2c_sht.sht4x.data_types.Sht4xRepeatability(value)[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.sht4x.response_types.Sht4xTemperature(ticks)[source]
Represents a measurement response for the temperature.
With the
ticksyou can access the raw data as received from the device. For the converted values you can choose betweendegrees_celsiusanddegrees_fahrenheit.- Parameters:
ticks (int) – The read ticks as received from the device.
- 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.sht4x.response_types.Sht4xHumidity(ticks)[source]
Represents a measurement response for the humidity.
With the
ticksyou can access the raw data as received from the device. For the converted value thepercent_rhattribute is available.- Parameters:
ticks (int) – The read ticks as received from the device.
- ticks
The ticks (int) as received from the device.
- percent_rh
The converted humidity in %RH.
STS4x
Sts4xI2cDevice
- class sensirion_i2c_sht.sts4x.device.Sts4xI2cDevice(connection, slave_address=68)[source]
STS4x I²C device class to allow executing I²C commands.
- __init__(connection, slave_address=68)[source]
Constructs a new STS4x 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=Sts4xRepeatability.HIGH)[source]
Trigger a measurement and read the temperature.
- Parameters:
repeatability (Sts4xRepeatability) – Configure the repeatability setting.
- Raises:
ValueError – If the passed repeatability is not valid.
- Returns:
The measured temperature
temperature (
Sts4xTemperature) - Temperature response object.
- Return type:
tuple
Sts4xI2cCommand
- class sensirion_i2c_sht.sts4x.commands.Sts4xI2cCmdBase(command, tx_data, rx_length, read_delay, post_processing_time=0.0)[source]
STS4x I²C base command.
- __init__(command, tx_data, rx_length, read_delay, post_processing_time=0.0)[source]
Constructs a new STS4x 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
commandis None too). An empty list means to send the write header (even ifcommandis 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.
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.
- class sensirion_i2c_sht.sts4x.commands.Sts4xI2cCmdMeasBase(command, read_delay)[source]
Base STS4x command for a single shot measurement.
- __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.
temperature (
Sts4xTemperature) - Temperature response object.
- Return type:
- class sensirion_i2c_sht.sts4x.commands.Sts4xI2cCmdMeasHighRes[source]
STS4x command for a single shot measurement with high repeatability.
- class sensirion_i2c_sht.sts4x.commands.Sts4xI2cCmdMeasMediumRes[source]
STS4x command for a single shot measurement with medium repeatability.
- class sensirion_i2c_sht.sts4x.commands.Sts4xI2cCmdMeasLowRes[source]
STS4x command for a single shot measurement with low repeatability.
- class sensirion_i2c_sht.sts4x.commands.Sts4xI2cCmdSoftReset[source]
STS4x command for a soft reset.
Data Types
Response Types
- class sensirion_i2c_sht.sts4x.response_types.Sts4xTemperature(ticks)[source]
Represents a measurement response for the temperature.
With the
ticksyou can access the raw data as received from the device. For the converted values you can choose betweendegrees_celsiusanddegrees_fahrenheit.- Parameters:
ticks (int) – The read ticks as received from the device.
- ticks
The ticks (int) as received from the device.
- degrees_celsius
The converted temperature in °C.
- degrees_fahrenheit
The converted temperature in °F.