API Documentation

SFM3304

Sfm3304Device

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

class sensirion_i2c_sfm3304.device.Sfm3304DeviceBase(channel)[source]

Low level API implementation of SFM3304

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

The sensor starts measuring both flow and temperature and provides a status word. All three measurement results can be read out through one single I2C read when the continuous measurement is running. This command uses the default low pass filter settin with a T63 of 3ms. To configure different low pass filter, use the specific method.

Note

The first measurement result will be available after 4ms. Small accuracy deviations (few % of reading) can occur during the first 50ms (including the 4ms)

start_continuous_measurement_with_filter(a_filter)[source]

The sensor starts measuring both flow and temperature and provides a status word. All three measurement results can be read out through one single I2C read when the continuous measurement is running.

Parameters:

a_filter – Filter setting for low pass filter on flow measurement. You can configure a time constant T63 by passing an integer from the following options: 1ms -> 33601, 3ms (default) -> 50961, 5ms -> 56105, 10ms -> 60527

Note

The first measurement result will be available after 4ms. Small accuracy deviations (few % of reading) can occur during the first 50ms (including the 4ms).

Example:
sensor.start_continuous_measurement_with_filter(50961)
read_measurement_data_raw()[source]

After a start continuous measurement command, the measurement results can be read out continuously with this command. The temperature and the consecutive bytes do not need to be read out (every time). The read sequence can be aborted by a NACK and a STOP condition.

Return flow:

Calibrated flow signal. Convert to gas flow in slm by (value - offset) / scale

Return temperature:

Calibrated temperature. Convert to degrees celsius by value / 200.

Return status_word:

Gives information about the measurement command that is currently running. A detailed description can be found in the data sheet.

Note

The first measurement result will be available after 4ms. Small accuracy deviations (few % of reading) can occur during the first 50ms (including the 4ms)

read_measurement_flow_raw()[source]

Read out only flow measurement from the sensor.

Return flow:

Calibrated flow signal read from the sensor.

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.

configure_averaging(average_window)[source]
This command configures the sensor’s averaging mode:
  • N=0 (default): average-until-read mode

  • 1≤N≤128: fixed-N averaging mode. N is the number of internal measurements that are averaged for one returned measurement value (i.e. the average over N flow samples, where N = CmdArgument, c.f. Sec. 3).

The configured averaging mode will be used for flow measurements until a reset or re-execution of this command is performed. After a reset, averaging is set to fixed-N averaging mode with N = 2. The highest averaging number allowed is 128. If a higher number is used in the command argument, it will be overruled by the maximal value of 128 samples to average. If no averaging is desired, set N to 1.

Parameters:

average_window – Average window configuration value.

Example:
sensor.configure_averaging(2)
read_scale_offset_unit(command_code)[source]

This command provides the scale factor and offset to convert flow readings into physical units. The scale factor and offset are specific to the calibrated gas and its corresponding lookup table used for the flow measurement. Therefore, the gas needs to be specified in the command argument by the command code of the corresponding start continuous measurement.

Parameters:

command_code – For the SFM3304-xxx-D the only calibrated gas is air, the command argument is 0x3603.

Return flow_scale_factor:

Scale factor used by the sensor.

Return flow_offset:

Offset used by the sensor.

Return flow_unit:

Applicable flow unit.

Note

For the SFM3304-xxx-D, the flow unit is a fixed value 0x0148 and corresponds to slm: standard liter per minute at 20°C and 1013.25 hPa pressure

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 performing measurements. 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.

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 16ms.

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.

Return product_identifier:

32-bit unique product and revision number. The number is listed in Table 13 below. Note that the last 8 bits are the revision number.

Return serial_number:

64-bit unique serial number in the format of an unsigned long integer. The serial number can be converted from binary into decimal, whereby in decimal it has the following format: yywwxxxxxx, where: yy: last 2 digits of calibration year, ww: calibration week, xxxxxx: unique 6-digit sequential number within the calibration week.

class sensirion_i2c_sfm3304.device.Sfm3304Device(channel)[source]

Driver class implementation of SFM3304

sfm3304

Access to base class

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

Read measurement data and apply appropriate scaling.

Return a_flow:

This signal represents the measured flow in slm (at 20°C and 1013.25hPa). It is scaled with the corresponding scaling factor and offset.

Return a_temperature:

Measured temperature in degrees Celsius. The raw value is scaled appropriately.

Return a_status_word:

read_measurement_flow()[source]

Read only the flow measurement data.

Return a_flow:

This signal represents the measured flow in slm (at 20°C and 1013.25hPa). It is scaled with the corresponding scaling factor and offset.

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_sfm3304.commands.ErrorCodeT(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]
I2C_ERROR = 0
TIMEOUT = 1
class sensirion_i2c_sfm3304.commands.FilterOptions(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]
T63_1MS = 33601
T63_3MS = 50961
T63_5MS = 56105
T63_10MS = 60527
class sensirion_i2c_sfm3304.commands.StatusWordT(int_value: int = 0)[source]
nr_of_averages = BitField(offset=0, width=9)
command_argument_reception = BitField(offset=9, width=1)
avg_mode_flag = BitField(offset=10, width=1)
exp_smoothing_flag = BitField(offset=11, width=1)
command_id = BitField(offset=12, width=4)
class sensirion_i2c_sfm3304.commands.FlowUnitT(int_value: int = 0)[source]
prefix = BitField(offset=0, width=4)
time_base = BitField(offset=4, width=4)
unit = BitField(offset=8, width=5)
class sensirion_i2c_sfm3304.commands.StartContinuousMeasurement[source]

The sensor starts measuring both flow and temperature and provides a status word. All three measurement results can be read out through one single I2C read when the continuous measurement is running. This command uses the default low pass filter settin with a T63 of 3ms. To configure different low pass filter, use the specific method.

CMD_ID = 13827
pack()[source]
tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
class sensirion_i2c_sfm3304.commands.StartContinuousMeasurementWithFilter(a_filter)[source]

The sensor starts measuring both flow and temperature and provides a status word. All three measurement results can be read out through one single I2C read when the continuous measurement is running.

CMD_ID = 13827
pack()[source]
tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
class sensirion_i2c_sfm3304.commands.ReadMeasurementDataRaw[source]

After a start continuous measurement command, the measurement results can be read out continuously with this command. The temperature and the consecutive bytes do not need to be read out (every time). The read sequence can be aborted by a NACK and a STOP condition.

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

Read out only flow measurement from the sensor.

pack()[source]
rx = <sensirion_driver_adapters.rx_tx_data.RxData object>
class sensirion_i2c_sfm3304.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_sfm3304.commands.ConfigureAveraging(average_window)[source]
This command configures the sensor’s averaging mode:
  • N=0 (default): average-until-read mode

  • 1≤N≤128: fixed-N averaging mode. N is the number of internal measurements that are averaged for one returned measurement value (i.e. the average over N flow samples, where N = CmdArgument, c.f. Sec. 3).

The configured averaging mode will be used for flow measurements until a reset or re-execution of this command is performed. After a reset, averaging is set to fixed-N averaging mode with N = 2. The highest averaging number allowed is 128. If a higher number is used in the command argument, it will be overruled by the maximal value of 128 samples to average. If no averaging is desired, set N to 1.

CMD_ID = 13930
pack()[source]
tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
class sensirion_i2c_sfm3304.commands.ReadScaleOffsetUnit(command_code)[source]

This command provides the scale factor and offset to convert flow readings into physical units. The scale factor and offset are specific to the calibrated gas and its corresponding lookup table used for the flow measurement. Therefore, the gas needs to be specified in the command argument by the command code of the corresponding start continuous measurement.

CMD_ID = 13921
pack()[source]
tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
rx = <sensirion_driver_adapters.rx_tx_data.RxData object>
class sensirion_i2c_sfm3304.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 performing measurements. 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.

CMD_ID = 13943
pack()[source]
tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
class sensirion_i2c_sfm3304.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 16ms.

CMD_ID = 0
pack()[source]
tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
class sensirion_i2c_sfm3304.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.

CMD_ID = 57602
pack()[source]
tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
rx = <sensirion_driver_adapters.rx_tx_data.RxData 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_sfm3304.result_types.SignalTemperature(temperature_raw)[source]

Measured temperature in degrees Celsius. The raw value is scaled appropriately.

property value
class sensirion_i2c_sfm3304.result_types.SignalFlow(flow_raw)[source]

This signal represents the measured flow in slm (at 20°C and 1013.25hPa). It is scaled with the corresponding scaling factor and offset.

property value