API Documentation

SDP

SdpI2cDevice

class sensirion_i2c_sdp.sdp.device.SdpI2cDevice(connection, slave_address=37)[source]

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

Adjust the I2C address according to your setup.

SDP8xx can support 0x25 and 0x26. SDP3x can support 0x21, 0x22 and 0x23.

Please refer to the dedicated Datasheet for more details on the supported I2C address range.

__init__(connection, slave_address=37)[source]

Constructs a new SDP I²C device.

Parameters:
  • connection (I2cConnection) – The I²C connection to use for communication.
  • slave_address (byte) – The I²C slave address, defaults to 0x25.
read_product_identifier()[source]

Read the product identifier and serial number of the sensor.

Returns:The product number and serial number.
Return type:tuple
start_continuous_measurement_with_mass_flow_t_comp_and_averaging()[source]

This command starts continuous measurements with mass flow temperature compensation and the average till read feature.

Note

The measurement command must only be sent once, if acknowledged. The command must not be resent or other commands must not be sent until the stop measurement command has been issued. After the start measurement command is sent, the first measurement result is available after 8ms. Small accuracy deviations (few % of reading) can occur during the next 12ms. The measured values are updated every 0.5ms and can be read using the read measurement interface.

start_continuous_measurement_with_mass_flow_t_comp()[source]

This command starts continuous measurements with mass flow temperature compensation.

Note

The measurement command must only be sent once, if acknowledged. The command must not be resent or other commands must not be sent until the stop measurement command has been issued. After the start measurement command is sent, the first measurement result is available after 8ms. Small accuracy deviations (few % of reading) can occur during the next 12ms. The measured values are updated every 0.5ms and can be read using the read measurement interface.

start_continuous_measurement_with_diff_pressure_t_comp_and_averaging()[source]

This command starts continuous measurements with differential pressure temperature compensation and the average till read feature.

Note

The measurement command must only be sent once, if acknowledged. The command must not be resent or other commands must not be sent until the stop measurement command has been issued. After the start measurement command is sent, the first measurement result is available after 8ms. Small accuracy deviations (few % of reading) can occur during the next 12ms. The measured values are updated every 0.5ms and can be read using the read measurement interface.

start_continuous_measurement_with_diff_pressure_t_comp()[source]

This command starts continuous measurements with differential pressure temperature compensation.

Note

The measurement command must only be sent once, if acknowledged. The command must not be resent or other commands must not be sent until the stop measurement command has been issued. After the start measurement command is sent, the first measurement result is available after 8ms. Small accuracy deviations (few % of reading) can occur during the next 12ms. The measured values are updated every 0.5ms and can be read using the read measurement interface.

trigger_measurement_with_mass_flow_t_comp_and_averaging()[source]

This command triggers a single shot measurement with mass flow temperature compensation.

Note

During a triggered measurement the sensor measures both differential pressure and temperature. The measurement starts directly after the command has been sent. The command needs to be repeated with every measurement. During the 45ms that the sensor is measuring, no command can be sent to the sensor. After the 45ms the result can be read out and any command can be sent to the sensor.

trigger_measurement_with_diff_pressure_t_comp_and_averaging()[source]

This command triggers a single shot measurement with differential pressure temperature compensation.

Note

During a triggered measurement the sensor measures both differential pressure and temperature. The measurement starts directly after the command has been sent. The command needs to be repeated with every measurement. During the 45ms that the sensor is measuring, no command can be sent to the sensor. After the 45ms the result can be read out and any command can be sent to the sensor.

stop_continuous_measurement()[source]

This command stops the continuous measurement and puts the sensor in idle mode. It powers off the heater and makes the sensor receptive to another command after 500us. The Stop command is also required when switching between different continuous measurement commands.

read_measurement()[source]

Read Measurement from sensor.

After a start continuous measurement commands, the measurement results can be read out at most every 0.5ms. After a triggered measurement command, the results can be read out when the sensor is finished with the measurement.

Returns:
  • differential_pressure (:py:class:sensirion_i2c_sdp.sdp.response_types.SdpDifferentialPressure) Differential Pressure response object
  • temperature (:py:class:sensirion_i2c_sdp.sdp.reasponse_types.SdpTemperature) Temperature response object.
Return type:tuple
enter_sleep_mode()[source]

In sleep mode the sensor uses the minimum amount of current. The mode can only be entered from idle mode, i.e. when the sensor is not measuring. This mode is particularly useful for battery operated devices. To minimize the current in this mode, the complexity of the sleep mode circuit has been reduced as much as possible, which is mainly reflected by the way the sensor exits the sleep mode. In sleep mode the sensor cannot be soft reset.

Note

Triggered mode: the sleep command can be sent after the result have been read out and the sensor is in idle mode. Continuous mode: the sleep command can be sent after a stop continuous measurement command has been issued and the sensor is in idle mode.

exit_sleep_mode()[source]

Exit sleep mode. See the data sheet for more detailed information

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

SdpI2cCommand

class sensirion_i2c_sdp.sdp.commands.SdpI2cCmdBase(command, tx_data, rx_length, read_delay, timeout, post_processing_time=0.0)[source]

SDP I²C base command.

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

Constructs a new SDP 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_sdp.sdp.commands.SdpI2cCmdStartContinuousMeasurementWithMassFlowTCompAndAveraging[source]

Start Continuous Measurement With Mass Flow T Comp And Averaging I²C Command

This command starts continuous measurements with mass flow temperature compensation and the average till read feature.

Note

The measurement command must only be sent once, if acknowledged. The command must not be resent or other commands must not be sent until the stop measurement command has been issued. After the start measurement command is sent, the first measurement result is available after 8ms. Small accuracy deviations (few % of reading) can occur during the next 12ms. The measured values are updated every 0.5ms and can be read using the read measurement interface.

__init__()[source]

Constructor.

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_sdp.sdp.commands.SdpI2cCmdStartContinuousMeasurementWithMassFlowTComp[source]

Start Continuous Measurement With Mass Flow T Comp I²C Command

This command starts continuous measurements with mass flow temperature compensation.

Note

The measurement command must only be sent once, if acknowledged. The command must not be resent or other commands must not be sent until the stop measurement command has been issued. After the start measurement command is sent, the first measurement result is available after 8ms. Small accuracy deviations (few % of reading) can occur during the next 12ms. The measured values are updated every 0.5ms and can be read using the read measurement interface.

__init__()[source]

Constructor.

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_sdp.sdp.commands.SdpI2cCmdStartContinuousMeasurementWithDiffPressureTCompAndAveraging[source]

Start Continuous Measurement With Diff Pressure T Comp And Averaging I²C Command

This command starts continuous measurements with differential pressure temperature compensation and the average till read feature.

Note

The measurement command must only be sent once, if acknowledged. The command must not be resent or other commands must not be sent until the stop measurement command has been issued. After the start measurement command is sent, the first measurement result is available after 8ms. Small accuracy deviations (few % of reading) can occur during the next 12ms. The measured values are updated every 0.5ms and can be read using the read measurement interface.

__init__()[source]

Constructor.

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_sdp.sdp.commands.SdpI2cCmdStartContinuousMeasurementWithDiffPressureTComp[source]

Start Continuous Measurement With Diff Pressure T Comp I²C Command

This command starts continuous measurements with differential pressure temperature compensation.

Note

The measurement command must only be sent once, if acknowledged. The command must not be resent or other commands must not be sent until the stop measurement command has been issued. After the start measurement command is sent, the first measurement result is available after 8ms. Small accuracy deviations (few % of reading) can occur during the next 12ms. The measured values are updated every 0.5ms and can be read using the read measurement interface.

__init__()[source]

Constructor.

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_sdp.sdp.commands.SdpI2cCmdStopContinuousMeasurement[source]

Stop Continuous Measurement I²C Command

This command stops the continuous measurement and puts the sensor in idle mode. It powers off the heater and makes the sensor receptive to another command after 500us. The Stop command is also required when switching between different continuous measurement commands.

__init__()[source]

Constructor.

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_sdp.sdp.commands.SdpI2cCmdTriggerMeasurementWithMassFlowTCompAndAveraging[source]

Trigger Measurement With Mass Flow T Comp And Averaging I²C Command

This command triggers a single shot measurement with mass flow temperature compensation.

Note

During a triggered measurement the sensor measures both differential pressure and temperature. The measurement starts directly after the command has been sent. The command needs to be repeated with every measurement. During the 45ms that the sensor is measuring, no command can be sent to the sensor. After the 45ms the result can be read out and any command can be sent to the sensor.

__init__()[source]

Constructor.

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_sdp.sdp.commands.SdpI2cCmdTriggerMeasurementWithDiffPressureTComp[source]

Trigger Measurement With Diff Pressure T Comp I²C Command

This command triggers a single shot measurement with differential pressure temperature compensation.

Note

During a triggered measurement the sensor measures both differential pressure and temperature. The measurement starts directly after the command has been sent. The command needs to be repeated with every measurement. During the 45ms that the sensor is measuring, no command can be sent to the sensor. After the 45ms the result can be read out and any command can be sent to the sensor.

__init__()[source]

Constructor.

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_sdp.sdp.commands.SdpI2cCmdReadMeasurement[source]

Read Measurement I²C Command

After a start continuous measurement commands, the measurement results can be read out at most every 0.5ms. After a triggered measurement command, the results can be read out when the sensor is finished with the measurement. The temperature and scale factor don’t need to be read out (every time). The read sequence can be aborted by a NACK and a STOP condition. The scale factor is for differential pressure in Pascal.

__init__()[source]

Constructor.

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:
  • differential_pressure (:py:class:sensirion_i2c_sdp.sdp.response_types.SdpDifferentialPressure) - The digital calibrated differential pressure signal read from the sensor is a signed integer number (two’s complement number). The integer value is converted to the physical value by dividing it by the scale factor, which is returned with every measurement.
  • temperature (:py:class:sensirion_i2c_sdp.sdp.reasponse_types.SdpTemperature) - The digital calibrated temperature signal read from the sensor is a signed integer number (two’s complement number). The integer value is converted to the physical value by dividing it by a scale factor of 200.
Return type:tuple
Raises:I2cChecksumError – If a received CRC was wrong.
class sensirion_i2c_sdp.sdp.commands.SdpI2cCmdEnterSleepMode[source]

Enter Sleep Mode I²C Command

In sleep mode the sensor uses the minimum amount of current. The mode can only be entered from idle mode, i.e. when the sensor is not measuring. This mode is particularly useful for battery operated devices. To minimize the current in this mode, the complexity of the sleep mode circuit has been reduced as much as possible, which is mainly reflected by the way the sensor exits the sleep mode. In sleep mode the sensor cannot be soft reset.

Note

Triggered mode: the sleep command can be sent after the result have been read out and the sensor is in idle mode. Continuous mode: the sleep command can be sent after a stop continuous measurement command has been issued and the sensor is in idle mode.

__init__()[source]

Constructor.

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_sdp.sdp.commands.SdpI2cCmdExitSleepMode[source]

Exit Sleep Mode I²C Command

Exit sleep mode. See the data sheet for more detailed information

__init__()[source]

Constructor.

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_sdp.sdp.commands.SdpI2cCmdPrepareProductIdentifier[source]

Prepare Product Identifier I²C Command

Prepare for reading the product identifier and sensor serial number.

__init__()[source]

Constructor.

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_sdp.sdp.commands.SdpI2cCmdReadProductIdentifier[source]

Read Product Identifier I²C Command

Read the product identifier and serial number of the sensor.

Note

Make sure to call ‘prepare product identifier’ immediately before.

__init__()[source]

Constructor.

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:
  • product_number (int) - 32 bit unique product and revision number. The number is listed in the datasheet. Note that the last 8 bits are the revision number and can be subject to change.
  • serial_number (unsigned long long) 64-bit unique serial number
Return type:tuple
Raises:I2cChecksumError – If a received CRC was wrong.

Data Types

Response Types

class sensirion_i2c_sdp.sdp.response_types.SdpTemperature(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_sdp.sdp.response_types.SdpDifferentialPressure(ticks, scale_factor)[source]

Represents a measurement response for the differential pressure.

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

Parameters:
  • ticks (int) – The read ticks as received from the device.
  • scale_factor (int) – The read scaling factor to convert the received differential pressure ticks as received from the sensor into Pascal.
__init__(ticks, scale_factor)[source]

Creates an instance from the received raw data.

ticks

The ticks (int) as received from the device.

scale_factor

The scale factor (int) as received from the device.

pascal

The converted concentration in vol%.