pi_weather.core.sensors.stcc4.handler module¶
Logic to handle and manage the STCC4 sensor
- class pi_weather.core.sensors.stcc4.handler.STCC4[source]¶
Bases:
objectBase class for STCC4 CO2 sensor
- calculation_crc(data)[source]¶
Calculate the CRC (Cyclic Redundancy Check) for input data Data words are succeeded by an 8-bit checksum (denoted as Cyclic Redundancy Check (CRC))
- get_product_id()[source]¶
Get the sensor ID
- Return type:
- Returns:
Sensor ID as bytes if successful, None otherwise
- start_measurement()[source]¶
Start continuous measurement
- Return type:
- Returns:
True if successful, False otherwise
- stop_measurement()[source]¶
Stop continuous measurement
- Return type:
- Returns:
True if successful, False otherwise
- single_measurement()[source]¶
Perform a single shot measurement
- Return type:
- Returns:
True if successful, False otherwise
- fall_asleep()[source]¶
Put the sensor into sleep mode
- Return type:
- Returns:
True if successful, False otherwise
- wakeup()[source]¶
Wake up the sensor from sleep mode
- Return type:
- Returns:
True if successful, False otherwise
- soft_reset()[source]¶
Perform a soft reset of the sensor
- Return type:
- Returns:
True if successful, False otherwise
- factory_reset()[source]¶
Perform a factory reset of the sensor
- Return type:
- Returns:
True if successful, False otherwise
- enable_testing_mode()[source]¶
Enable testing mode
- Return type:
- Returns:
True if successful, False otherwise
- class pi_weather.core.sensors.stcc4.handler.STCC4I2C(i2c_addr=100, bus=3)[source]¶
Bases:
STCC4STCC4I2C class Use the I2C protocol to drive the STCC4 sensor
- get_product_id()[source]¶
Function retrieving and returning the sensor product ID
- Returns:
Sensor product ID
- Return type:
- start_measurement()[source]¶
Function to start measurements
Starts continuous measurement with 1s sampling interval. Note that the sensor and the microcontroller are subject to clock tolerances. The effective sampling interval is 1s +/- 150 ms.
- Returns:
True if successful, False otherwise
- Return type:
- stop_measurement()[source]¶
Function to stop continuous measurements
The stop_continuous_measurement command will finish the currently running measurement before returning to idle mode. During the execution time, the sensor will not acknowledge its I2C address nor accept commands.
- Returns:
True if successful, False otherwise
- Return type:
- set_rht_compensation(temperature, humidity)[source]¶
Function to set relative humidity + temperature compensation values
- single_measurement()[source]¶
Function to perform a single-short measurement
The measure_single_shot command conducts an on-demand measurement of CO2 gas concentration.
- Returns:
True if command was successful, False otherwise
- Return type:
- fall_asleep()[source]¶
Function to make the sensor fall asleep
The enter_sleep_mode command sets the sensor from idle to sleep mode through the I2C interface. The written relative humidity, temperature, pressure compensation values and ASC state are retained while in sleep mode.
- Returns:
True if command was successful, False otherwise
- Return type:
- wakeup()[source]¶
Function to wake up the sensor
The exit_sleep_mode command wakes the sensor up from sleep mode to idle mode upon receiving its I2C address, a write data direction bit and a payload byte 0x00.
- Returns:
True if command was successful, False otherwise
- Return type:
- soft_reset()[source]¶
Function to perform a soft reset
The perform_soft_reset command triggers a soft reset of the sensor through the I2C general call reset as implemented according to the NXP I2C-bus specification and user manual
- Returns:
True if command was successful, False otherwise
- Return type:
- factory_reset()[source]¶
Function to perform a factory reset
The perform_factory_reset command resets the FRC and ASC algorithm history :return: True if command was successful, False otherwise
- Return type:
- forced_recalibration(target_ppm)[source]¶
Function to forced recalibration
The perform_forced_recalibration command (FRC) is used to correct the sensor’s CO2 concentration output with an externally provided target CO2 concentration.
Ensure the sensor reading and environmental conditions, including CO2 concentration, are stable for the duration of the recommended operation sequence. See Section 3.5 for the signal output and input conversion.