API Reference

adafruit_stcc4

CircuitPython driver for the STCC4 and SHT41 - CO2, Temperature and Humidity Sensor

  • Author(s): Liz Clark

Implementation Notes

Hardware:

Software and Dependencies:

adafruit_stcc4.STATUS_DEBUG = 14

Debug flags mask.

adafruit_stcc4.STATUS_MEMORY_ERROR = 96

Memory error flags mask.

adafruit_stcc4.STATUS_SHT_NOT_CONNECTED = 16

SHT sensor not connected flag.

adafruit_stcc4.STATUS_TESTING_MODE = 16384

Testing mode active flag.

adafruit_stcc4.STATUS_VOLTAGE_ERROR = 1

Supply voltage error flag.

class adafruit_stcc4.STCC4(i2c_bus: busio.I2C, address: int = _STCC4_DEFAULT_ADDR)

Driver for the STCC4 CO2 sensor with integrated SHT41.

Parameters:
  • i2c_bus (I2C) – The I2C bus the STCC4 is connected to.

  • address (int) – The I2C device address. Defaults to 0x64.

property CO2: int

CO2 concentration in parts per million (ppm).

If continuous measurement is not active, a single-shot measurement is triggered automatically.

Returns:

CO2 concentration in ppm.

Return type:

int

property continuous_measurement: bool

Enable or disable continuous measurement with a 1 s sampling interval.

Parameters:

value (bool) – True to start, False to stop.

Returns:

Current continuous measurement state.

Return type:

bool

factory_reset() None

Perform a factory reset, clearing FRC and ASC algorithm history.

forced_recalibration(reference_co2: int) int

Perform forced recalibration (FRC) using a known CO2 reference.

Parameters:

reference_co2 (int) – Known CO2 concentration in ppm.

Returns:

FRC correction value. 0xFFFF indicates failure.

Return type:

int

measure_single_shot() None

Trigger a single-shot measurement and wait for it to complete.

After calling this method, read CO2, temperature, and relative_humidity to retrieve the results.

perform_conditioning() None

Run sensor conditioning to improve initial CO2 accuracy.

Warning

This blocks for approximately 22 seconds.

pressure_compensation(pressure_hpa: int) None

Ambient pressure for CO2 compensation.

Parameters:

pressure_hpa (int) – Ambient pressure in hPa (e.g. 1013 for sea level).

property product_id: int

32-bit product identifier.

Returns:

Product ID read from the sensor.

Return type:

int

property relative_humidity: float

Relative humidity as a percentage.

Note

Call CO2 first to trigger a fresh measurement, or use measure_single_shot() / continuous_measurement(). This property returns the value from the most recent reading.

Returns:

Relative humidity in %.

Return type:

float

reset() None

Perform a soft reset of the sensor.

rht_compensation(rht_value: int) None

External RH/T compensation value.

Parameters:

rht_value (int) – 16-bit RH/T compensation value per datasheet.

self_test() int

Run the built-in self-test.

Returns:

Self-test result. 0 indicates no errors detected.

Return type:

int

property sleep_mode: None

Sleep mode is write-only; reading is not supported.

property status: int

Raw status word from the most recent measurement.

Compare against the STATUS_* constants to check for specific conditions.

Returns:

16-bit status word.

Return type:

int

property temperature: float

Temperature in degrees Celsius.

Note

Call CO2 first to trigger a fresh measurement, or use measure_single_shot() / continuous_measurement(). This property returns the value from the most recent reading.

Returns:

Temperature in °C.

Return type:

float