API Reference¶
Svm40I2cDevice¶
-
class
sensirion_i2c_svm40.device.Svm40I2cDevice(connection, slave_address=106)[source]¶ SVM40 I²C device class to allow executing I²C commands.
-
__init__(connection, slave_address=106)[source]¶ Constructs a new SVM40 I²C device.
Parameters: - connection (I2cConnection) – The I²C connection to use for communication.
- slave_address (byte) – The I²C slave address, defaults to 0x6A.
-
get_serial_number()[source]¶ Get the serial number of the device.
Returns: The serial number as a hex formatted ASCII string. Return type: string
-
get_version()[source]¶ Get the version of the device firmware, hardware and SHDLC protocol.
Returns: The device version. Return type: Version
-
get_compensation_temperature_offset()[source]¶ Gets the temperature offset for RHT measurements.
Returns: Temperature offset in degrees celsius. Return type: float
-
set_compensation_temperature_offset(t_offset)[source]¶ Sets the temperature offset for RHT measurements.
Note
Execute the command
store_nv_data()command after writing the parameter to store it in the non-volatile memory of the device otherwise the parameter will be reset upton a device reset.Parameters: t_offset (float) – Temperature offset in degrees celsius.
-
get_voc_tuning_parameters()[source]¶ Gets the currently set parameters for customizing the VOC algorithm.
Returns: - voc_index_offset (int) - VOC index representing typical (average) conditions. The default value is 100.
- learning_time_hours (int) - Time constant of long-term estimator in hours. Past events will be forgotten after about twice the learning time. The default value is 12 hours.
- gating_max_duration_minutes (int) - Maximum duration of gating in minutes (freeze of estimator during high VOC index signal). Zero disables the gating. The default value is 180 minutes.
- std_initial (int) - Initial estimate for standard deviation. Lower value boosts events during initial learning period, but may result in larger device-to-device variations. The default value is 50.
Return type: tuple
-
set_voc_tuning_parameters(voc_index_offset, learning_time_hours, gating_max_duration_minutes, std_initial)[source]¶ Sets parameters to customize the VOC algorithm. This command is only available in idle mode.
Note
Execute the command
store_nv_data()after writing the parameter to store it in the non-volatile memory of the device otherwise the parameter will be reset upton a device reset.Parameters: - voc_index_offset (int) – VOC index representing typical (average) conditions. The default value is 100.
- learning_time_hours (int) – Time constant of long-term estimator in hours. Past events will be forgotten after about twice the learning time. The default value is 12 hours.
- gating_max_duration_minutes (int) – Maximum duration of gating in minutes (freeze of estimator during high VOC index signal). Set to zero to disable the gating. The default value is 180 minutes.
- std_initial (int) – Initial estimate for standard deviation. Lower value boosts events during initial learning period, but may result in larger device-to-device variations. The default value is 50.
-
get_voc_state()[source]¶ Gets the current VOC algorithm state. Retrieved values can be used to set the VOC algorithm state to resume operation after a short interruption, skipping initial learning phase. This command is only available during measurement mode.
Note
This feature can only be used after at least 3 hours of continuous operation.
Returns: Current VOC algorithm state. Return type: list(int)
-
set_voc_state(state)[source]¶ Set previously retrieved VOC algorithm state to resume operation after a short interruption, skipping initial learning phase. This command is only available in idle mode.
Note
This feature should not be used after interruptions of more than 10 minutes.
Parameters: state (list(int)) – Current VOC algorithm state.
-
start_measurement()[source]¶ Starts continuous measurement in polling mode.
Note
This command is only available in idle mode.
-
stop_measurement()[source]¶ Leaves the measurement mode and returns to the idle mode.
Note
This command is only available in measurement mode.
-
read_measured_values()[source]¶ Returns the new measurement results.
Note
This command is only available in measurement mode. The firmware updates the measurement values every second. Polling data with a faster sampling rate will return the same values. The first measurement is available 1 second after the start measurement command is issued. Any readout prior to this will return zero initialized values.
Returns: The measured air quality, humidity and temperature. - air_quality (
AirQuality) - Air quality response object. - humidity (
Humidity) - Humidity response object. - temperature (
Temperature) - Temperature response object.
Return type: tuple - air_quality (
-
read_measured_values_raw()[source]¶ Returns the new measurement results with raw values added.
Note
This command is only available in measurement mode. The firmware updates the measurement values every second. Polling data with a faster sampling rate will return the same values. The first measurement is available 1 second after the start measurement command is issued. Any readout prior to this will return zero initialized values.
Returns: The measured air quality, humidity and temperature including the raw values without algorithm compensation. - air_quality (
AirQuality) - Air quality response object. - humidity (
Humidity) - Humidity response object. - temperature (
Temperature) - Temperature response object. - raw_voc_ticks (int) - Raw VOC output ticks as read from the SGP sensor.
- raw_humidity (
Humidity) - Humidity response object. - raw_temperature (
Temperature) - Temperature response object.
Return type: tuple - air_quality (
-
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
-
Response Data Types¶
Air Quality¶
-
class
sensirion_i2c_svm40.response_types.AirQuality(ticks)[source]¶ Represents a measurement response for the air quality.
With the
ticksyou can access the raw data as received from the device. For the converted value thevoc_indexattribute is available.-
__init__(ticks)[source]¶ Creates an instance from the received raw data.
Parameters: ticks (int) – The read ticks as received from the device.
-
ticks¶ The ticks (int) as received from the device.
-
voc_index¶ The converted VOC index.
-
Humidity¶
-
class
sensirion_i2c_svm40.response_types.Humidity(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.-
__init__(ticks)[source]¶ Creates an instance from the received raw data.
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.
-
Temperature¶
-
class
sensirion_i2c_svm40.response_types.Temperature(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.-
__init__(ticks)[source]¶ Creates an instance from the received raw data.
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.
-
Version¶
-
class
sensirion_i2c_svm40.version_types.FirmwareVersion(major, minor, debug)[source]¶ Class representing the firmware version of a device.
-
class
sensirion_i2c_svm40.version_types.HardwareVersion(major, minor)[source]¶ Class representing the hardware version of a device.
-
class
sensirion_i2c_svm40.version_types.ProtocolVersion(major, minor)[source]¶ Class representing the I2C protocol version of an I2C device.
-
class
sensirion_i2c_svm40.version_types.Version(firmware, hardware, protocol)[source]¶ Class representing all version numbers of an I2C device. This is used for the “Get Version” command.
-
__init__(firmware, hardware, protocol)[source]¶ Constructor.
Parameters: - firmware (FirmwareVersion) – Firmware version.
- hardware (HardwareVersion) – Hardware version.
- protocol (ProtocolVersion) – SHDLC protocol version.
-
Commands¶
-
class
sensirion_i2c_svm40.commands.generated.Svm40I2cCmdGetSerialNumber[source]¶ Get Serial Number I²C Command
Gets the serial number from the device.
-
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: Ascii string containing the serial number. The string has the null-termination character included. Return type: str Raises: I2cChecksumError – If a received CRC was wrong.
-
-
class
sensirion_i2c_svm40.commands.generated.Svm40I2cCmdDeviceReset[source]¶ Device Reset I²C Command
Executs a reset on the device.
Note
The device will reply before executing the reset.
-
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_svm40.commands.generated.Svm40I2cCmdStartContinuousMeasurement[source]¶ Start Continuous Measurement I²C Command
Starts continuous measurement in polling mode.
Note
This command is only available in idle mode.
-
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_svm40.commands.generated.Svm40I2cCmdStopMeasurement[source]¶ Stop Measurement I²C Command
Stops the measurement mode and returns to idle mode.
Note
This command is only available in measurement mode.
-
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_svm40.commands.generated.Svm40I2cCmdGetVocAlgorithmTuningParameters[source]¶ Get Voc Algorithm Tuning Parameters I²C Command
Gets the currently set parameters for customizing the VOC algorithm
-
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: - voc_index_offset (int) - VOC index representing typical (average) conditions. The default value is 100.
- learning_time_hours (int) - Time constant of long-term estimator in hours. Past events will be forgotten after about twice the learning time. The default value is 12 hours.
- gating_max_duration_minutes (int) - Maximum duration of gating in minutes (freeze of estimator during high VOC index signal). Zero disables the gating. The default value is 180 minutes.
- std_initial (int) - Initial estimate for standard deviation. Lower value boosts events during initial learning period, but may result in larger device-to-device variations. The default value is 50.
Return type: tuple Raises: I2cChecksumError – If a received CRC was wrong.
-
-
class
sensirion_i2c_svm40.commands.generated.Svm40I2cCmdSetVocAlgorithmTuningParameters(voc_index_offset, learning_time_hours, gating_max_duration_minutes, std_initial)[source]¶ Set Voc Algorithm Tuning Parameters I²C Command
Sets the parameters to customize the VOC algorithm. This command is only available in idle mode.
-
__init__(voc_index_offset, learning_time_hours, gating_max_duration_minutes, std_initial)[source]¶ Constructor.
Parameters: - voc_index_offset (int) – VOC index representing typical (average) conditions. The default value is 100.
- learning_time_hours (int) – Time constant of long-term estimator in hours. Past events will be forgotten after about twice the learning time. The default value is 12 hours.
- gating_max_duration_minutes (int) – Maximum duration of gating in minutes (freeze of estimator during high VOC index signal). Set to zero to disable the gating. The default value is 180 minutes.
- std_initial (int) – Initial estimate for standard deviation. Lower value boosts events during initial learning period, but may result in larger device-to-device variations. The default value is 50.
-
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_svm40.commands.generated.Svm40I2cCmdGetVocAlgorithmState[source]¶ Get Voc Algorithm State I²C Command
Gets the current VOC algorithm state.
-
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: Current VOC algorithm state. Return type: list(int) Raises: I2cChecksumError – If a received CRC was wrong.
-
-
class
sensirion_i2c_svm40.commands.generated.Svm40I2cCmdSetVocAlgorithmState(state)[source]¶ Set Voc Algorithm State I²C Command
Sets the VOC algorithm state. This command is only available in idle mode.
-
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_svm40.commands.generated.Svm40I2cCmdStoreNvData[source]¶ Store Nv Data I²C Command
Stores all algorithm parameters to the non-volatile memory.
-
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_svm40.commands.wrapped.Svm40I2cCmdGetVersion[source]¶ Get Version I²C Command
Gets the version information for the hardware, firmware and protocol.
-
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: The device version as a Version object. Return type: Version Raises: I2cChecksumError – If a received CRC was wrong.
-
-
class
sensirion_i2c_svm40.commands.wrapped.Svm40I2cCmdReadMeasuredValues[source]¶ Returns the new measurement results.
Note
This command is only available in measurement mode. The firmware updates the measurement values every second. Polling data with a faster sampling rate will return the same values. The first measurement is available 1 second after the start measurement command is issued. Any readout prior to this will return zero initialized values.
-
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: The measured air quality, humidity and temperature. - air_quality (
AirQuality) - Air quality response object. - humidity (
Humidity) - Humidity response object. - temperature (
Temperature) - Temperature response object.
Return type: tuple Raises: I2cChecksumError – If a received CRC was wrong. - air_quality (
-
-
class
sensirion_i2c_svm40.commands.wrapped.Svm40I2cCmdReadMeasuredValuesRaw[source]¶ Returns the new measurement results with raw values added.
Note
This command is only available in measurement mode. The firmware updates the measurement values every second. Polling data with a faster sampling rate will return the same values. The first measurement is available 1 second after the start measurement command is issued. Any readout prior to this will return zero initialized values.
-
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: The measured air quality, humidity and temperature including the raw values without algorithm compensation. - air_quality (
AirQuality) - Air quality response object. - humidity (
Humidity) - Humidity response object. - temperature (
Temperature) - Temperature response object. - raw_voc_ticks (int) - Raw VOC output ticks as read from the SGP sensor.
- raw_humidity (
Humidity) - Humidity response object. - raw_temperature (
Temperature) - Temperature response object.
Return type: tuple Raises: I2cChecksumError – If a received CRC was wrong. - air_quality (
-
-
class
sensirion_i2c_svm40.commands.wrapped.Svm40I2cCmdGetTemperatureOffsetForRhtMeasurements[source]¶ Get Temperature Offset For Rht Measurements I²C Command
Gets the T-Offset for the temperature compensation of the RHT algorithm.
-
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 offset in degrees celsius. Return type: float Raises: I2cChecksumError – If a received CRC was wrong.
-
-
class
sensirion_i2c_svm40.commands.wrapped.Svm40I2cCmdSetTemperatureOffsetForRhtMeasurements(t_offset)[source]¶ Set Temperature Offset For Rht Measurements I²C Command
Sets the T-Offset for the temperature compensation of the RHT algorithm.
-
__init__(t_offset)[source]¶ Constructor.
Parameters: t_offset (float) – Temperature offset in degrees celsius.
-
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.
-