API Documentation
STCC4
Stcc4Device
The class Stcc4DeviceBase implements the low level interface of the sensor. The class Stcc4Device extends the Stcc4DeviceBase. It provides additional functions to ease the use of the sensor.
- class sensirion_i2c_stcc4.device.Stcc4DeviceBase(channel)[source]
Low level API implementation of STCC4
- property channel
- start_continuous_measurement()[source]
After sending the start_continuous_measurement command, the sensor will begin measuring the CO2 gas concentration continuously with a sampling interval of 1 second. The recommended communication sequence for continuous measurement is as follows: 1. The sensor is powered up into the idle state. 2. The I2C controller sends a start_continuous_measurement command. 3. The I2C controller periodically reads out data with the read_measurement command. 4. If desired, stop taking measurements using the stop_continuous_measurement command.
- read_measurement_raw()[source]
After the command start_continuous_measurement has been sent, the chip continuously measures and updates the measurement results. New results (co2_concentration, temperature, and relative_humidity) can be read continuously with this command.
- Return co2_concentration_raw:
CO2 concentration in ppm. No conversion needed.
- Return temperature_raw:
Raw temperature signal. The signal s can be converted into a temperature in °C (t) by applying the formula t = -45 + 175 * s / 65535.
- Return relative_humidity_raw:
Raw relative humidity signal. The signal s can be converted into relative humidity in % (rh) by applying the formula rh = -6 + 125 * s / 65535.
- Return sensor_status_raw:
The sensor status. If the sensor is in testing mode, byte 10 is equal to 4.
- stop_continuous_measurement()[source]
After receiving the stop_continuous_measurement command, the sensor will finish the currently running measurement before returning to idle mode. Therefore, a wait time of one measurement interval plus a 200 ms clock tolerance is required before a new command is acknowledged.
- measure_single_shot()[source]
The measure_single_shot command conducts an on-demand measurement of CO2 gas concentration. The typical communication sequence is as follows: 1. The sensor is powered up with the exit_sleep_mode command if previously powered down using the enter_sleep_mode command. 2. The I2C controller sends a measure_single_shot command and waits for the execution time. 3. The I2C controller reads out data with the read_measurement command. 4. Repeat steps 2-3 as required by the application. 5. If desired, set the sensor to sleep with the enter_sleep_mode command.
- perform_forced_recalibration(target_CO2_concentration)[source]
The forced recalibration (FRC) can be applied to correct the sensor’s output by means of an externally obtained CO 2 reference value. The recommended communication sequence for a successful FRC in continuous mode is as follows: 1. Operate the STCC4 for at least 3 minutes. Ensure the sensor reading and environmental conditions, including CO2 concentration, are stable. 2. The I2C controller sends the stop_continuous_measurement command (Section 5.3.2) 3. Wait for the specified execution time of stop_continuous_measurement command. 4. Issue the perform_forced_recalibration command with the target CO2 concentration and read out the applied FRC correction.
The recommended communication sequence for a successful FRC in single shot mode is as follows: 1. Operate the STCC4 for at least 3 minutes. For sampling intervals significantly larger than 10 seconds, increase the operation time accordingly. Ensure the sensor reading and environmental conditions, including CO2 concentration, are stable. 2. Issue the perform_forced_recalibration command with the reference CO2 concentration and read out the applied FRC correction. The sensor must remain in idle mode after operation before command execution.
- Parameters:
target_co2_concentration – Target CO₂ concentration in ppm.
- Return frc_correction:
Returns the FRC correction value if FRC has been successful. 0xFFFF on failure.
- get_product_id()[source]
The get_product_ID command retrieves the product identifier and serial number. The command can be used to check communication with the sensor.
- Return product_id:
32-bit
- Return serial_number:
64-bit unique serial number of the sensor.
- set_rht_compensation(raw_temperature, raw_humidity)[source]
When the SHT4x is not directly connected to the STCC4 for humidity and temperature compensation, the set_rht_compensation command allows external input of relative humidity (RH) and temperature (T) values. The temperature value must be provided from the RHT sensor providing the RH value for correct absolute humidity calculation. The written RHT values are applied for compensation after a maximum of one measurement interval. The default or last written values are used for RHT compensation until overwritten. Power cycling resets the sensor to the default values of 25°C and 50 %RH.
- Parameters:
raw_temperature – raw temperature ticks as provided by SHT4x sensor
raw_humidity – raw humidity ticks as provided by SHT4x sensor
- Example:
sensor.set_rht_compensation(26214, 29359)
- set_pressure_compensation_raw(pressure)[source]
External pressure values can be set through the set_pressure_compensation command. The written pressure value is applied for pressure compensation after a maximum of one measurement interval. Power cycling resets the sensor to the default value of 101’300 Pa. The default or the last written value is used in pressure compensation until overwritten.
- Parameters:
pressure – The pressure value as Pa divided by 2. E.g. for 101300 Pa you have to send 50650
- Example:
sensor.set_pressure_compensation_raw(50650)
- perform_self_test()[source]
The perform_self_test command can be used as an end-of-line test to check the sensor functionality. Word[0] = 0 → pass Word[0] ≠ 0 → malfunction detected
- Return test_result:
Test result of the self-test. If the result is ≠ 0, the self-test failed.
- perform_conditioning()[source]
The perform_conditioning command is recommended to improve sensor performance when the sensor has not completed measurements for more than 3 hours. It is recommended to allow a settling time of 2 seconds after the execution time is complete. The recommended communication sequence is as follows: 1. The sensor is woken up with the exit_sleep_mode command if previously put to sleep using the enter_sleep_mode command. 2. The I2C controller sends a perform_conditioning command. 3. Wait for the specified execution time of perform_conditioning command plus a 2 second settling time. 4. The I2C controller sends a measurement command (e.g. start_continuous_measurement command or measure_single_shot command.
- enter_sleep_mode()[source]
The enter_sleep_mode command sets the sensor to sleep mode through the I2C interface. The written relative humidity, temperature, and pressure compensation values as well as the ASC state will be retained while in sleep mode.
- exit_sleep_mode()[source]
The exit_sleep_mode command sets the sensor to idle mode through the I2C interface. The sensor’s idle state can be verified by reading out the product ID.
- enable_testing_mode()[source]
The enable_testing_mode command is used to test the sensor with the ASC algorithm disabled. The sensor state can be verified by reading out the sensor status word in the read_measurement command.
- class sensirion_i2c_stcc4.device.Stcc4Device(channel)[source]
Driver class implementation of STCC4
- stcc4
Access to base class
- read_measurement()[source]
reads measurement data
- Return co2_concentration:
- Return temperature:
- Return relative_humidity:
- Return sensor_status:
- set_pressure_compensation(pressure)[source]
External pressure values can be set through the set_pressure_compensation command. The written pressure value is applied for pressure compensation after a maximum of one measurement interval. Power cycling resets the sensor to the default value of 101’300 Pa.
- Parameters:
pressure –
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_stcc4.commands.StartContinuousMeasurement[source]
After sending the start_continuous_measurement command, the sensor will begin measuring the CO2 gas concentration continuously with a sampling interval of 1 second. The recommended communication sequence for continuous measurement is as follows: 1. The sensor is powered up into the idle state. 2. The I2C controller sends a start_continuous_measurement command. 3. The I2C controller periodically reads out data with the read_measurement command. 4. If desired, stop taking measurements using the stop_continuous_measurement command.
- CMD_ID = 8587
- tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
- class sensirion_i2c_stcc4.commands.ReadMeasurementRaw[source]
After the command start_continuous_measurement has been sent, the chip continuously measures and updates the measurement results. New results (co2_concentration, temperature, and relative_humidity) can be read continuously with this command.
- CMD_ID = 60421
- tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
- rx = <sensirion_driver_adapters.rx_tx_data.RxData object>
- class sensirion_i2c_stcc4.commands.StopContinuousMeasurement[source]
After receiving the stop_continuous_measurement command, the sensor will finish the currently running measurement before returning to idle mode. Therefore, a wait time of one measurement interval plus a 200 ms clock tolerance is required before a new command is acknowledged.
- CMD_ID = 16262
- tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
- class sensirion_i2c_stcc4.commands.MeasureSingleShot[source]
The measure_single_shot command conducts an on-demand measurement of CO2 gas concentration. The typical communication sequence is as follows: 1. The sensor is powered up with the exit_sleep_mode command if previously powered down using the enter_sleep_mode command. 2. The I2C controller sends a measure_single_shot command and waits for the execution time. 3. The I2C controller reads out data with the read_measurement command. 4. Repeat steps 2-3 as required by the application. 5. If desired, set the sensor to sleep with the enter_sleep_mode command.
- CMD_ID = 8605
- tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
- class sensirion_i2c_stcc4.commands.PerformForcedRecalibration(target_CO2_concentration)[source]
The forced recalibration (FRC) can be applied to correct the sensor’s output by means of an externally obtained CO 2 reference value. The recommended communication sequence for a successful FRC in continuous mode is as follows: 1. Operate the STCC4 for at least 3 minutes. Ensure the sensor reading and environmental conditions, including CO2 concentration, are stable. 2. The I2C controller sends the stop_continuous_measurement command (Section 5.3.2) 3. Wait for the specified execution time of stop_continuous_measurement command. 4. Issue the perform_forced_recalibration command with the target CO2 concentration and read out the applied FRC correction.
The recommended communication sequence for a successful FRC in single shot mode is as follows: 1. Operate the STCC4 for at least 3 minutes. For sampling intervals significantly larger than 10 seconds, increase the operation time accordingly. Ensure the sensor reading and environmental conditions, including CO2 concentration, are stable. 2. Issue the perform_forced_recalibration command with the reference CO2 concentration and read out the applied FRC correction. The sensor must remain in idle mode after operation before command execution.
- CMD_ID = 13871
- tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
- rx = <sensirion_driver_adapters.rx_tx_data.RxData object>
- class sensirion_i2c_stcc4.commands.GetProductId[source]
The get_product_ID command retrieves the product identifier and serial number. The command can be used to check communication with the sensor.
- CMD_ID = 13915
- tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
- rx = <sensirion_driver_adapters.rx_tx_data.RxData object>
- class sensirion_i2c_stcc4.commands.SetRhtCompensation(raw_temperature, raw_humidity)[source]
When the SHT4x is not directly connected to the STCC4 for humidity and temperature compensation, the set_rht_compensation command allows external input of relative humidity (RH) and temperature (T) values. The temperature value must be provided from the RHT sensor providing the RH value for correct absolute humidity calculation. The written RHT values are applied for compensation after a maximum of one measurement interval. The default or last written values are used for RHT compensation until overwritten. Power cycling resets the sensor to the default values of 25°C and 50 %RH.
- CMD_ID = 57344
- tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
- class sensirion_i2c_stcc4.commands.SetPressureCompensationRaw(pressure)[source]
External pressure values can be set through the set_pressure_compensation command. The written pressure value is applied for pressure compensation after a maximum of one measurement interval. Power cycling resets the sensor to the default value of 101’300 Pa. The default or the last written value is used in pressure compensation until overwritten.
- CMD_ID = 57366
- tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
- class sensirion_i2c_stcc4.commands.PerformSelfTest[source]
The perform_self_test command can be used as an end-of-line test to check the sensor functionality. Word[0] = 0 → pass Word[0] ≠ 0 → malfunction detected
- CMD_ID = 10124
- tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
- rx = <sensirion_driver_adapters.rx_tx_data.RxData object>
- class sensirion_i2c_stcc4.commands.PerformConditioning[source]
The perform_conditioning command is recommended to improve sensor performance when the sensor has not completed measurements for more than 3 hours. It is recommended to allow a settling time of 2 seconds after the execution time is complete. The recommended communication sequence is as follows: 1. The sensor is woken up with the exit_sleep_mode command if previously put to sleep using the enter_sleep_mode command. 2. The I2C controller sends a perform_conditioning command. 3. Wait for the specified execution time of perform_conditioning command plus a 2 second settling time. 4. The I2C controller sends a measurement command (e.g. start_continuous_measurement command or measure_single_shot command.
- CMD_ID = 10684
- tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
- class sensirion_i2c_stcc4.commands.EnterSleepMode[source]
The enter_sleep_mode command sets the sensor to sleep mode through the I2C interface. The written relative humidity, temperature, and pressure compensation values as well as the ASC state will be retained while in sleep mode.
- CMD_ID = 13904
- tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
- class sensirion_i2c_stcc4.commands.ExitSleepMode[source]
The exit_sleep_mode command sets the sensor to idle mode through the I2C interface. The sensor’s idle state can be verified by reading out the product ID.
- CMD_ID = 0
- tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
- class sensirion_i2c_stcc4.commands.EnableTestingMode[source]
The enable_testing_mode command is used to test the sensor with the ASC algorithm disabled. The sensor state can be verified by reading out the sensor status word in the read_measurement command.
- CMD_ID = 16316
- tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
- class sensirion_i2c_stcc4.commands.DisableTestingMode[source]
The disable_testing_mode command is used to exit the testing mode. The sensor state can be verified by reading out the sensor status word in the read_measurement command.
- CMD_ID = 16189
- 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.