API Documentation

SBN4X

Sbn4xDevice

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

class sensirion_i2c_sbn4x.device.Sbn4xDeviceBase(channel)[source]

Low level API implementation of SBN4X

__init__(channel)[source]
property channel
start_periodic_measurement_mode(sampling_rate)[source]

Starts periodic measurement of O2, humidity, temperature, pressure and CO2. After starting the measurement, it takes some time (~20ms) until the first measurement results are available. The command 0x02 read measured values will return an error 0x20 no measurement data available until the first results are available. This command is only available in idle mode. If the device is already in any measure mode, or the requested sampling rate is not supported, this command has no effect.

Parameters:

sampling_rate – Sampling rate of the measurement in [mHz]. The actual sampling rate in Hz is the value divided by 1000. The only valid sampling rate is 30 Hz (30000 mHz).

Example:
sensor.start_periodic_measurement_mode(30000)
stop_measurement()[source]

Stops the measurement and returns to idle mode. The last measurement results can still be read out, if available. If the device is already in idle mode, this command has no effect.

read_measurements_raw()[source]

Read the measured values O2, CO2 and ambient conditions from the sensor. Each set of measurements is identified by the measurement counter.

Return measurement_counter:

The measurement counter is incremented with each measurement in the periodic measurement mode. A counter value of 0 indicates that no measurement has been taken so far. The measurement counters can be used to disambiguate the data returned by the sensor.

Return o2_dry_percent:

The O2 concentration in 1/256 % of the measured gas when the humidity in the gas is compensated. In order to obtain the O2 concentration in %, the value has to be divided by 256.

Return co2_dry_percent:

The CO2 concentration in 1/256 % of the measured gas. In order to obtain the CO2 concentration in %, the value has to be divided by 256.

Return respiratory_exchange_ratio:

Respiratory exchange ratio (RER), dimensionless. The value is provided in 1/256 units. To obtain the RER as a floating-point value, divide by 256.

Return pressure:

The pressure 1/256 Pa. In order to obtain the pressure in Pa, the value has to be divided by 256.

force_o2_recalibration()[source]

Force a recalibration of the O2 sensor. This command is executed in measurement mode only. The measurement loop is interrupted until the recalibration is done and the new calibration value is written to flash. After this, the sensor resumes measuring using the updated configuration value.

start_forced_co2_recalibration()[source]

Force a recalibration of the CO2 sensor. This command is executed only when the sensor is in periodic mode. There is no measurement data available until the recalibration is fully applied to the CO2 sensor. After this, the sensor resumes measuring using the updated calibration value.

get_forced_co2_recalibration_status()[source]

Get the status of the forced recalibration. This function can be polled after starting a forced CO2 recalibration. The returned value is 0xFFFF as long as the forced recalibration is running, and changes to 0 if the forced recalibration is completed.

Return forced_recalibration_status:

Status of the forced recalibration.

get_product_type()[source]

Gets the product type from the device.

Return product_type:

Null-terminated string containing the product type.

get_product_name()[source]

Gets the product name from the device.

Return product_name:

Null-terminated ASCII string containing the product name. Up to 32 characters can be read from the device.

get_article_code()[source]

Gets the article code from the device.

Return article_code:

Null-terminated ASCII string containing the article code. Up to 32 characters can be read from the device.

get_serial_number()[source]

Gets the serial number from the device.

Return serial_number:

Null-terminated ASCII string containing the serial number. Up to 32 characters can be read from the device.

get_device_uid()[source]

Gets the device uid from the device.

Return device_uid:

96 bit unique microcontroller UID in binary format.

get_version()[source]

Gets the version information for the hardware, firmware and communication protocol.

Return firmware_major:

Firmware major version number.

Return firmware_minor:

Firmware minor version number.

Return firmware_develop_flag:

Firmware develop flag. False for released firmware.

Return hardware_major:

Hardware major version number.

Return hardware_minor:

Hardware minor version number.

Return protocol_major:

Protocol major version number.

Return protocol_minor:

Protocol minor version number.

Return padding:

Padding byte, ignore this.

read_device_status()[source]

Reads the current device status. Use this command to get detailed information about the device status. The device status is encoded in flags. Each device status flag represents a single bit in a 32-bit integer value. If more than one error is present, the device status register value is the sum of the corresponding flag values. For details about the available flags, refer to the device status flags documentation.

Return device_status:

Device status (32 flags as an integer value). For details, please refer to the device status flags documentation.

Note

The status flags of type “Error” are sticky, i.e. they are not cleared automatically even if the error condition no longer exists. So they can only be cleared manually with the command 0xD210 “Read And Clear Device Status” or with a device reset. All other flags are not sticky, i.e. they are cleared automatically if the trigger condition disappears.

read_and_clear_device_status()[source]

Reads the current device status (like command 0xD206 “Read Device Status”) and afterwards clears all flags.

Return device_status:

Device status (32 flags as an integer value) before clearing it. For details, please refer to the device status flags documentation.

device_reset()[source]

Executes a reset on the device. This has the same effect as a power cycle.

class sensirion_i2c_sbn4x.device.Sbn4xDevice(channel)[source]

Driver class implementation of SBN4X

sbn4x

Access to base class

__init__(channel)[source]
read_measurements()[source]

Read the measured values of the sensor

Return measurement_counter:

The measurement counter is incremented with each measurement in the periodic measurement mode. A counter value of 0 indicates that no measurement has been taken so far. The measurement counters can be used to disambiguate the data returned by the sensor.

Return o2_dry_percent:

The measured O₂ concentration

Return co2_dry_percent:

The measured CO₂ concentration

Return respiratory_exchange_ratio:

The measured respiratory exchange ratio (RER), dimensionless

Return pressure:

The measured pressure in Pa

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_sbn4x.commands.StartPeriodicMeasurementMode(sampling_rate)[source]

Starts periodic measurement of O2, humidity, temperature, pressure and CO2. After starting the measurement, it takes some time (~20ms) until the first measurement results are available. The command 0x02 read measured values will return an error 0x20 no measurement data available until the first results are available. This command is only available in idle mode. If the device is already in any measure mode, or the requested sampling rate is not supported, this command has no effect.

CMD_ID = 16
pack()[source]
tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
class sensirion_i2c_sbn4x.commands.StopMeasurement[source]

Stops the measurement and returns to idle mode. The last measurement results can still be read out, if available. If the device is already in idle mode, this command has no effect.

CMD_ID = 260
pack()[source]
tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
class sensirion_i2c_sbn4x.commands.ReadMeasurementsRaw[source]

Read the measured values O2, CO2 and ambient conditions from the sensor. Each set of measurements is identified by the measurement counter.

CMD_ID = 608
pack()[source]
tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
rx = <sensirion_driver_adapters.rx_tx_data.RxData object>
class sensirion_i2c_sbn4x.commands.ForceO2Recalibration[source]

Force a recalibration of the O2 sensor. This command is executed in measurement mode only. The measurement loop is interrupted until the recalibration is done and the new calibration value is written to flash. After this, the sensor resumes measuring using the updated configuration value.

CMD_ID = 768
pack()[source]
tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
class sensirion_i2c_sbn4x.commands.StartForcedCO2Recalibration[source]

Force a recalibration of the CO2 sensor. This command is executed only when the sensor is in periodic mode. There is no measurement data available until the recalibration is fully applied to the CO2 sensor. After this, the sensor resumes measuring using the updated calibration value.

CMD_ID = 1287
pack()[source]
tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
class sensirion_i2c_sbn4x.commands.GetForcedCO2RecalibrationStatus[source]

Get the status of the forced recalibration. This function can be polled after starting a forced CO2 recalibration. The returned value is 0xFFFF as long as the forced recalibration is running, and changes to 0 if the forced recalibration is completed.

CMD_ID = 1297
pack()[source]
tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
rx = <sensirion_driver_adapters.rx_tx_data.RxData object>
class sensirion_i2c_sbn4x.commands.GetProductType[source]

Gets the product type from the device.

CMD_ID = 53250
pack()[source]
tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
rx = <sensirion_driver_adapters.rx_tx_data.RxData object>
class sensirion_i2c_sbn4x.commands.GetProductName[source]

Gets the product name from the device.

CMD_ID = 53268
pack()[source]
tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
rx = <sensirion_driver_adapters.rx_tx_data.RxData object>
class sensirion_i2c_sbn4x.commands.GetArticleCode[source]

Gets the article code from the device.

CMD_ID = 53285
pack()[source]
tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
rx = <sensirion_driver_adapters.rx_tx_data.RxData object>
class sensirion_i2c_sbn4x.commands.GetSerialNumber[source]

Gets the serial number from the device.

CMD_ID = 53299
pack()[source]
tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
rx = <sensirion_driver_adapters.rx_tx_data.RxData object>
class sensirion_i2c_sbn4x.commands.GetDeviceUid[source]

Gets the device uid from the device.

CMD_ID = 53329
pack()[source]
tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
rx = <sensirion_driver_adapters.rx_tx_data.RxData object>
class sensirion_i2c_sbn4x.commands.GetVersion[source]

Gets the version information for the hardware, firmware and communication protocol.

CMD_ID = 53504
pack()[source]
tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
rx = <sensirion_driver_adapters.rx_tx_data.RxData object>
class sensirion_i2c_sbn4x.commands.ReadDeviceStatus[source]

Reads the current device status. Use this command to get detailed information about the device status. The device status is encoded in flags. Each device status flag represents a single bit in a 32-bit integer value. If more than one error is present, the device status register value is the sum of the corresponding flag values. For details about the available flags, refer to the device status flags documentation.

CMD_ID = 53766
pack()[source]
tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
rx = <sensirion_driver_adapters.rx_tx_data.RxData object>
class sensirion_i2c_sbn4x.commands.ReadAndClearDeviceStatus[source]

Reads the current device status (like command 0xD206 “Read Device Status”) and afterwards clears all flags.

CMD_ID = 53776
pack()[source]
tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
rx = <sensirion_driver_adapters.rx_tx_data.RxData object>
class sensirion_i2c_sbn4x.commands.DeviceReset[source]

Executes a reset on the device. This has the same effect as a power cycle.

CMD_ID = 54020
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_sbn4x.result_types.SignalI16ToFloat(value)[source]

Return the scaled int16_t value as unscaled floating point value.

property value
class sensirion_i2c_sbn4x.result_types.SignalU32ToFloat(value)[source]

Return the scaled uint32_t value as unscaled floating point value.

property value