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.
device_reset()[source]

Execute a device reset (reboot firmware, similar to power cycle).

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.
store_nv_data()[source]

Stores all customer engine parameters to the non-volatile memory.

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
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
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 ticks you can access the raw data as received from the device. For the converted value the voc_index attribute 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 ticks you can access the raw data as received from the device. For the converted value the percent_rh attribute 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 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.

__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.

__init__(major, minor, debug)[source]

Constructor.

Parameters:
  • major (byte) – Major version (0..255).
  • minor (byte) – Minor version (0..99).
  • debug (bool) – Debug flag (False for official releases).
class sensirion_i2c_svm40.version_types.HardwareVersion(major, minor)[source]

Class representing the hardware version of a device.

__init__(major, minor)[source]

Constructor.

Parameters:
  • major (byte) – Major version (0..255).
  • minor (byte) – Minor version (0..99).
class sensirion_i2c_svm40.version_types.ProtocolVersion(major, minor)[source]

Class representing the I2C protocol version of an I2C device.

__init__(major, minor)[source]

Constructor.

Parameters:
  • major (byte) – Major version (0..255).
  • minor (byte) – Minor version (0..99).
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:

Commands