API Reference¶
Sfm3019I2cDevice¶
-
class
sensirion_sensorbridge_i2c_sfm.sfm3019.device.
Sfm3019I2cSensorBridgeDevice
(sensor_bridge, sensor_bridge_port, slave_address=46)[source]¶ SFM3019 I²C device class to allow executing I²C commands via Sensirion’s SensorBridge.
-
__init__
(sensor_bridge, sensor_bridge_port, slave_address=46)[source]¶ Constructs a new SFM3019 I²C device.
Parameters: - sensor_bridge (SensorBridgeShdlcDevice) – The I²C SHDLC SensorBridge connection to use for communication.
- sensor_bridge_port (int) – The port on the SensorBridge which the sensor is connected to.
- slave_address (byte) – The I²C slave address, defaults to 0x2E.
-
flow_unit
¶ Returns: The flow unit as a string according to datasheet Return type: str
-
initialize_sensor
(measure_mode)[source]¶ Stop any running continuous measurement that may execute on the sensor and read out some sensor parameters.
Needs to be done before any measurement call is executed.
-
read_product_identifier_and_serial_number
()[source]¶ Read the product identifier and serial number.
Returns: The product identifier (4b) and serial number (12b), both formatted as decimal number (int). Return type: tuple
-
start_continuous_measurement
(measure_mode=<MeasurementMode.Air: (1, )>, air_o2_mix_fraction_permille=None)[source]¶ Start a continuous measurement with the specified gas
Parameters: - measure_mode (MeasurementMode) – Configure the type of measurement to perform. Check the datasheet for more information.
- air_o2_mix_fraction_permille (int) – Fraction (in permille 0-1000) of O2 contained in the Air/O2 Mix. This parameter is only used when measure_mode is ‘AirO2Mix’.
-
Sfm3019I2cCommand¶
-
class
sensirion_sensorbridge_i2c_sfm.sfm3019.commands.
Sfm3019I2cCmdBase
(command, tx_words, rx_length, read_delay, timeout)[source]¶ SFM3019 I²C base command.
-
__init__
(command, tx_words, rx_length, read_delay, timeout)[source]¶ Constructs a new SFM3019 I²C 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. - tx_words (list/None) – Words (list of integers) to be 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 ifcommand
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.
- command (int/None) – The command word to be sent to the device. None means that no
command will be sent, i.e. only
-
interpret_response
(data)¶ Converts the raw response from the device to words (2 bytes), checks their CRC and retunrs the checked words.
Parameters: data (bytes) – Received raw bytes from the read operation. Returns: The received words, or None if there is no data received. Return type: list(int) or None Raises: I2cChecksumError – If a received CRC was wrong.
-
-
class
sensirion_sensorbridge_i2c_sfm.sfm3019.commands.
Sfm3019I2cCmdReadProductIdentifierAndSerialNumber
[source]¶ SFM3019 I²C command “Read Product Identifier and Serial Number”.
-
interpret_response
(data)[source]¶ Converts the raw response from the device to words (2 bytes), checks their CRC and retunrs the checked words.
Parameters: data (bytes) – Received raw bytes from the read operation. Returns: The received words, or None if there is no data received. Return type: list(int) or None Raises: I2cChecksumError – If a received CRC was wrong.
-
-
class
sensirion_sensorbridge_i2c_sfm.sfm3019.commands.
Sfm3019I2cCmdStartMeasO2
[source]¶ SFM3019 I²C command “Start continuous Measurement of O2”
-
interpret_response
(data)¶ Converts the raw response from the device to words (2 bytes), checks their CRC and retunrs the checked words.
Parameters: data (bytes) – Received raw bytes from the read operation. Returns: The received words, or None if there is no data received. Return type: list(int) or None Raises: I2cChecksumError – If a received CRC was wrong.
-
-
class
sensirion_sensorbridge_i2c_sfm.sfm3019.commands.
Sfm3019I2cCmdStartMeasAir
[source]¶ SFM3019 I²C command “Start continuous Measurement of Air”
-
interpret_response
(data)¶ Converts the raw response from the device to words (2 bytes), checks their CRC and retunrs the checked words.
Parameters: data (bytes) – Received raw bytes from the read operation. Returns: The received words, or None if there is no data received. Return type: list(int) or None Raises: I2cChecksumError – If a received CRC was wrong.
-
-
class
sensirion_sensorbridge_i2c_sfm.sfm3019.commands.
Sfm3019I2cCmdStartMeasAirO2Mix
(o2_volume_fraction_in_permille)[source]¶ SFM3019 I²C command “Start continuous Measurement of Air/O2 with Volume fraction of O2 (in ‰)”
-
interpret_response
(data)¶ Converts the raw response from the device to words (2 bytes), checks their CRC and retunrs the checked words.
Parameters: data (bytes) – Received raw bytes from the read operation. Returns: The received words, or None if there is no data received. Return type: list(int) or None Raises: I2cChecksumError – If a received CRC was wrong.
-
-
class
sensirion_sensorbridge_i2c_sfm.sfm3019.commands.
Sfm3019I2cCmdReadMeas
[source]¶ SFM3019 I²C command “Read continuous measurement”
-
interpret_response
(data)[source]¶ Converts the raw response from the device to words (2 bytes), checks their CRC and retunrs the checked words.
Parameters: data (bytes) – Received raw bytes from the read operation. Returns: The received words, or None if there is no data received. Return type: list(int) or None Raises: I2cChecksumError – If a received CRC was wrong.
-
-
class
sensirion_sensorbridge_i2c_sfm.sfm3019.commands.
Sfm3019I2cCmdStopMeas
[source]¶ SFM3019 I²C command “Stop continuous measurements”
-
interpret_response
(data)¶ Converts the raw response from the device to words (2 bytes), checks their CRC and retunrs the checked words.
Parameters: data (bytes) – Received raw bytes from the read operation. Returns: The received words, or None if there is no data received. Return type: list(int) or None Raises: I2cChecksumError – If a received CRC was wrong.
-
-
class
sensirion_sensorbridge_i2c_sfm.sfm3019.commands.
Sfm3019I2cCmdGetUnitAndFactors
(measure_cmd)[source]¶ SFM3019 I²C command “Get the currently set scale factor and unit for the defined measurement mode”
-
interpret_response
(data)[source]¶ Converts the raw response from the device to words (2 bytes), checks their CRC and retunrs the checked words.
Parameters: data (bytes) – Received raw bytes from the read operation. Returns: The received words, or None if there is no data received. Return type: list(int) or None Raises: I2cChecksumError – If a received CRC was wrong.
-