API Documentation

LD20

Ld20Device

The class Ld20DeviceBase implements the low level interface of the sensor. The class Ld20Device extends the Ld20DeviceBase. It provides additional functions to ease the use of the sensor.

class sensirion_i2c_ld20.device.Ld20DeviceBase(channel)[source]

Low level API implementation of LD20

__init__(channel)[source]
property channel
start_continuous_measurement()[source]

Starts continuous measurement mode. The sensor measures both the flow rate and the temperature. After the command has been sent, the chip continuously measures and updates the measurement results which can be read with read_measurement_data_raw.

Note

The first measurement result will be available after 12ms. Due to the thermal measurement principle small accuracy deviations (% m.v.) can occur while the sensor warms-up (120ms including the 12 ms for measurement initialization).

read_measurement_data_raw()[source]

After the command start_h2o_continuous_measurement has been sent, the chip continuously measures and updates the measurement results. New results (flow, temperature, and signaling flags) can be read continuously with this command.

Return raw_flow:

For LD20-0600L convert to ml/h by applying: flow = raw_flow / 1200 For LD20-2600B convert to ml/h by applying: flow = raw_flow / 20

Return raw_temperature:

Convert to degrees celsius by temperature = raw_temperature / 200

Return signaling_flags:

Gives additional information about the measurement status. Refer to the sensor data sheet for detailed information. Following flags are defined: Air-in-Line flag (Bit 0), High Flow flag (Bit 1), Exponential smoothing active (Bit 5)

Note

The first measurement result will be available 12ms after starting the measurement. Small accuracy deviations (% m.v.) can occur during the first 120ms (including the 12ms initialization)

stop_continuous_measurement()[source]

This command stops the continuous measurement and puts the sensor in idle mode. After it receives the stop command, the sensor needs up to 0.5ms to power down the heater, enter idle mode and be receptive for a new command.

enter_sleep()[source]

In sleep mode the sensor uses a minimum amount of power. 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. Supported by products: LD20-0600L, LD20-2600B

exit_sleep()[source]

The sensor exits the sleep mode and enters the idle mode when it receives the valid I2C address and a write bit (‘0’). Note that the I2C address is not acknowledged. It is necessary to poll the sensor to see whether the sensor has received the address and has woken up. This should take typically 25ms. Supported by products: LD20-0600L, LD20-2600B

read_product_identifier_prepare()[source]

Prepare to read the product identifier and the serial number. The command can only be executed from the idle mode, i.e. when the sensor is not performing measurements.

read_product_identifier()[source]

This command allows to read product identifier and the serial number. The command can only be executed from the idle mode, i.e. when the sensor is not performing measurements and read_product_identifier_prepare is called before.

Return product_identifier:

Note that the last 8 bits are the sensor’s revision number and are subject to change in case of an update of the specifications.

Return serial_number_high:

Higher 32-bit of the 64-bit unique serial number

Return serial_number_low:

Lower 32-bit of the 64-bit unique serial number

class sensirion_i2c_ld20.device.Ld20Device(channel)[source]

Driver class implementation of LD20

ld20

Access to base class

__init__(channel)[source]
read_measurement_data(inv_flow_scale_factor)[source]

Reads the raw measurement values and converts them to their physcial units where applicable. For the flow the scaling factor and resulting flow unit depends on the specific sensor. The scaling factor is passed as an argument and the raw flow value is converted by applying: flow = raw_flow / inv_flow_scale_factor The scaling factors for the supported sensor are defined in enum inv_flow_scale_factors

Parameters:

inv_flow_scale_factor – used to convert raw flow value

Return a_flow:

As the flow scaling differs for specific sensor types the scaling factor must be passed as an argument. See the enum inv_flow_scale_factors for scaling factors of supported sensors. The raw value is converted by: flow = raw_flow / inv_flow_scale_factor Resulting unit depends on your specific sensor type.

Return a_temperature:

temperature in degree celsius

Return a_signaling_flags:

read_product_identifier()[source]

Read product identifier and the serial number. The command can only be executed from the idle mode, i.e. when the sensor is not performing measurements.

Return product_identifier:

Return serial_number:

Commands

The transfer classes specify the data that is transferred between host and sensor. The generated transfer classes are used by the driver class and not intended for direct use.

class sensirion_i2c_ld20.commands.InvFlowScaleFactors(value)[source]
LD20_0600L = 1200
LD20_2600B = 20
class sensirion_i2c_ld20.commands.SignalingFlagsT(int_value: int = 0, **kwargs)[source]
air_in_line_flag = (0, 1)
high_flow_flag = (1, 1)
unused = (2, 3)
exp_smoothing_active = (5, 1)
class sensirion_i2c_ld20.commands.ReadMeasurementDataRaw[source]

After the command start_h2o_continuous_measurement has been sent, the chip continuously measures and updates the measurement results. New results (flow, temperature, and signaling flags) can be read continuously with this command.

pack()[source]
rx = <sensirion_driver_adapters.rx_tx_data.RxData object>
class sensirion_i2c_ld20.commands.StopContinuousMeasurement[source]

This command stops the continuous measurement and puts the sensor in idle mode. After it receives the stop command, the sensor needs up to 0.5ms to power down the heater, enter idle mode and be receptive for a new command.

CMD_ID = 16377
pack()[source]
tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
class sensirion_i2c_ld20.commands.EnterSleep[source]

In sleep mode the sensor uses a minimum amount of power. 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. Supported by products: LD20-0600L, LD20-2600B

CMD_ID = 13943
pack()[source]
tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
class sensirion_i2c_ld20.commands.ExitSleep[source]

The sensor exits the sleep mode and enters the idle mode when it receives the valid I2C address and a write bit (‘0’). Note that the I2C address is not acknowledged. It is necessary to poll the sensor to see whether the sensor has received the address and has woken up. This should take typically 25ms. Supported by products: LD20-0600L, LD20-2600B

CMD_ID = 0
pack()[source]
tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
class sensirion_i2c_ld20.commands.ReadProductIdentifierPrepare[source]

Prepare to read the product identifier and the serial number. The command can only be executed from the idle mode, i.e. when the sensor is not performing measurements.

CMD_ID = 13948
pack()[source]
tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
class sensirion_i2c_ld20.commands.ReadProductIdentifier[source]

This command allows to read product identifier and the serial number. The command can only be executed from the idle mode, i.e. when the sensor is not performing measurements and read_product_identifier_prepare is called before.

CMD_ID = 57602
pack()[source]
tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
rx = <sensirion_driver_adapters.rx_tx_data.RxData object>
class sensirion_i2c_ld20.commands.StartContinuousMeasurement[source]

Starts continuous measurement mode. The sensor measures both the flow rate and the temperature. After the command has been sent, the chip continuously measures and updates the measurement results which can be read with read_measurement_data_raw.

CMD_ID = 13832
pack()[source]
tx = <sensirion_driver_adapters.rx_tx_data.TxData object>

Result Types

The signal classes specify transformations of the raw sensor signals into a meaningful units. The generated signal types are used by the driver class and not intended for direct use.

class sensirion_i2c_ld20.result_types.SignalFlow(raw_flow, inv_flow_scale_factor)[source]

As the flow scaling differs for specific sensor types the scaling factor must be passed as an argument. See the enum inv_flow_scale_factors for scaling factors of supported sensors. The raw value is converted by: flow = raw_flow / inv_flow_scale_factor Resulting unit depends on your specific sensor type.

property value
class sensirion_i2c_ld20.result_types.SignalTemperature(raw_temperature)[source]

temperature in degree celsius

property value
class sensirion_i2c_ld20.result_types.SignalDeltaTemperature(raw_delta_temperature)[source]

delta temperature in degree celsius

property value