API Documentation
Protocols:
- class sensirion_uart_scc1.protocols.i2c_transceiver.I2cTransceiver(*args, **kwargs)
- execute(slave_addr: int, rx_tx: RxTx) Tuple[Any, ...]
Compatibility method for driver adapters.
- Parameters:
slave_addr – i2c slave address
rx_tx – Object containing the information to execute the communication with the device
- Returns:
interpreted results
- transceive(slave_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:
slave_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 repsonse 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, slave_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.
- 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_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_type() int | None
- Returns:
the configured sensor type
- 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
- sensor_reset() None
Execute a hard reset on the sensor and check for the correct response. Active continuous/single measurement is stopped, and the sensor is left in idle state.
- property serial_number: str
- 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
- transceive(command: int, data: bytes | Iterable, timeout: float = -1.0) bytes | None
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 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
- get_flow_unit_and_scale(command: int | None = None) Tuple[int, int] | None
Get the scale factor, unit and sensor sanity check result of the sensor for the given argument. (only available on some SLF3x sensor products)
- Parameters:
command – The 16-bit command to read flow unit and scale factor for. If no value is supplied the actual measurement command is used
- Returns:
A tuple with (scale_factor, flow_unit), None if command is not supported
- get_last_measurement() Tuple[int, int, int] | None
Read current measurement and starts internal continuous measurement with configured interval, if not already started.
- Returns:
A tuple with flow, temperature and flag
- get_liquid_mode_name(mode: SlfMode) str
Get the name of the liquid
- Parameters:
mode – A liquid mode
- Returns:
Get name of a specific liquid measurement mode
- get_serial_number() int
Get the serial number of the device.
- Returns:
The sensor serial number
- property liquid_mode: SlfMode
Liquid measurement mode
- property liquid_mode_name: str
Get the name of the liquid.
- Returns:
Name of current liquid measurement mode
- property product_id: int
Get the product Id
- Returns:
The product identifier as integer
- read_extended_buffer() Tuple[int, int, List[Tuple[Any, ...]]]
Read out measurement buffer
- Returns:
A tuple with (bytes_remaining, bytes_lost, data)
- property sampling_interval_ms: int
Sampling interval for synchronous measurement
- Returns:
Current internal sampling interval
- property serial_number: int
Get the serial number
- Returns:
The serial number as integer
- start_continuous_measurement(interval_ms=0) None
Start a continuous measurement with a give interval.
- Parameters:
interval_ms – Measurement interval in milliseconds.
- stop_continuous_measurement() None
Stop continuous measurement