API Documentation

Protocols:

class sensirion_uart_scc1.protocols.i2c_transceiver.I2cTransceiver(*args, **kwargs)
execute(target_address: int, rx_tx: RxTx) Tuple[Any, ...] | None

Compatibility method for driver adapters.

Parameters:
  • target_address – I2c address or the sensor

  • rx_tx – Object containing the information to execute the communication with the device

Returns:

interpreted results

transceive(target_address: int, tx_data: bytes | None, rx_length: int | None, read_delay: float, timeout: float) bytes

Send data to the sensor and receive back a response. This function can be used for sending or receiving only as well.

Parameters:
  • target_address – I2c address of the sensor.

  • tx_data – The data to be sent. In case no data shall be sent, this parameter is supposed to be None

  • rx_length – Length of the response of the sensor. If the request does not have a response, this parameter may be 0.

  • read_delay – Defines the time in seconds that needs to be observed after sending the data before the read is initiated.

  • timeout – Defines the time after receiving the response from the sensor before the next command may be sent.

class sensirion_uart_scc1.protocols.i2c_transceiver.RxTx(*args, **kwargs)

An object which conforms to this protocol is supplied by the I2cChannel when using the public python drivers.

interpret_response(data: bytes | None) Tuple[Any, ...] | None

Split the byte array from the response into the fields of the command.

Parameters:

data – The byte array that needs to be interpreted.

Returns:

A tuple with the interpreted data.

property read_delay: float

Time between writing and reading an i2c command.

property rx_length: int | None

Number of bytes to read

property tx_data: bytes | None

The byte array with the data to be sent

class sensirion_uart_scc1.protocols.shdlc_transceiver.ShdlcTransceiver(*args, **kwargs)
transceive(command: int, data: bytes | Iterable, timeout: float = -1.0) bytes | None

Wrapper method for legacy shdlc-driver compatibility.

Parameters:
  • command – The command to send (one byte)

  • data – byte array of the data to send as arguments to the command

  • timeout – response timeout in seconds (-1 for using default value)

Returns:

The returned data as bytes

Exceptions:

exception sensirion_uart_scc1.scc1_exceptions.Scc1InvalidDataReceived

Indicates the reception of invalid data from the device

exception sensirion_uart_scc1.scc1_exceptions.Scc1InvalidProductId(product_id: int)

Indicates a product id that is not supported

exception sensirion_uart_scc1.scc1_exceptions.Scc1NotSupportedException

Indicates a feature that is not (yet) supported.

Scc1ShdlcDevice:

class sensirion_uart_scc1.scc1_shdlc_device.Scc1ShdlcDevice(connection: ShdlcConnection, target_address: int = 0)

The Scc1 SHDLC device is used to communicate with various sensors using the Sensirion SCC1 sensor cable.

property com_port: str
property connected_i2c_addresses: List[int]

Returns the connected I2C addresses. You need to call find_chips to fill this attribute.

device_selftest() int

Execute a device selftest. :return: Selftest result (0: success, other: error code).

find_chips() List[int]

Looking for chips on all ports and sets the _connected_i2c_addresses attribute :return: List of connected addresses

property firmware_version: Version
get_continuous_measurement_status() int | None

Get the interval or status of the Continuous Measurement.

Returns:

Measurement interval in ms if started, None if not started.

get_i2c_delay() int

Get the I2C delay. :return: The I2C delay in microseconds

get_i2c_transceiver() I2cTransceiver

An I2cTransceiver object is required in or der to use the cable with public python i2c drivers.

In general, all functionality of the sensors is available in the public python drivers as well. The throughput of the public python driver will be lower than the throughput that can be achieved with the sensor-specific api of the SCC1 sensor cable.

get_sensor_address() int | None
Returns:

the configured i2c address

get_sensor_part_name(sensor_type: int) str

Get the part name of the connected sensor. :param sensor_type: The sensors’ type :return: the sensors’ part name as string

get_sensor_serial_number(sensor_type: int) str

Get the serial number of the connected sensor. :param sensor_type: The sensors type :return: the sensor serial number as string

get_sensor_status() int | None

Get the status of sensor and continuous measurement.

Returns:

Sensor status as integer, None if not available.

get_sensor_type() int | None
Returns:

the configured sensor type

get_sensor_voltage() int

Get the configured sensor supply voltage. :return: Sensor voltage (0: 3.3V, 1: 5.0V).

get_totalizator_status() bool | None

Get the Status (enabled / disabled) of the Totalizator. :return: True if the totalizator is enabled, False if disabled

get_totalizator_value() int | None

Get the value of the Totalizator. This value is the sum of all unscaled measurements while in continuous measurement. Note for sensor type 3 only: Only the flow values (signal 1) are totalized, and the values are interpreted as i16 signed integers. :return: Totalizator value

get_user_data(block_number: int = 0) bytes

Get 20 bytes of User Data from EEPROM. :param block_number: The block number to read (0..4). :return: 20 bytes of user data.

i2c_transceive(i2c_address: int, tx_data: bytes, rx_length: int, timeout_ms: int) bytes

Perform an I2C transceive operation. :param i2c_address: The I2C address :param tx_data: data to transmit :param rx_length: the number of bytes to receive :param timeout_ms: timeout in milliseconds :return: received data

measure_sensor_voltage() int

Measure the sensor supply voltage. :return: Output voltage in mV.

perform_i2c_scan() List[int]

Looks for i2c devices within a certain range on a certain port :return: List of i2c addresses that responded to the scan

reset_totalizator() None

Set the Totalizator value to zero, the Totalizator Status (enabled/disabled) is not changed. The Totalizator can be reset anytime.

sensor_reset() None

Execute a hard reset on the sensor. Sensor must be idle for execution of this command. Active continuous/single measurement is stopped, and the sensor is left in the idle state.

property serial_number: str
set_i2c_delay(delay_us: int) None

Set the I2C delay. :param delay_us: The I2C delay in microseconds

set_sensor_address(i2c_address: int) None

Configure the sensors i2c address and write it to EEPROM :param i2c_address: the i2c address

set_sensor_type(sensor_type: int)

Set sensor type 0: Flow Sensor (SF04 based products) 1: Humidity Sensor (SHTxx products) 2: Flow Sensor (SF05 based products) 3: Flow Sensor (SF06 based products) (Firmware ≥1.7) 4: Reserved :param sensor_type: One of the supported sensor types 0-4

set_sensor_voltage(voltage: int) None

Set the sensor supply voltage. :param voltage: Sensor voltage (0: 3.3V, 1: 5.0V).

set_totalizator_status(enabled: bool) None

Enable or disable the Totalizator. The value of the Totalizator is not changed with this command. :param enabled: True to enable the totalizator, false to disable it

set_user_data(block_number: int, data: bytes) None

Save 20 bytes of User Data in EEPROM. :param block_number: The block number to write (0..4). :param data: 20 bytes of user data.

transceive(command: int, data: bytes | Iterable, timeout: float = -1.0) bytes

Provides a generic way to send SHDLC commands.

Parameters:
  • command – The command to send (one byte).

  • data – Byte array of the data to send as arguments to the command.

  • timeout – Response timeout in seconds (-1 for using the default value).

Returns:

The returned data as bytes.

Drivers:

class sensirion_uart_scc1.drivers.scc1_slf3x.Scc1Slf3x(device: Scc1ShdlcDevice, liquid_mode: SlfMode = SlfMode.LIQUI_1)

Scc1 SLF3x Sensor Driver

The Scc1 provides features to support the SLF3x liquid flow sensors. This driver accesses the sensor through the API specified by scc1.

SENSOR_TYPE = 3

Sensor type for SLF3x

START_MEASUREMENT_DELAY_S = 0.015