Skip to main content

Crate stcc4

Crate stcc4 

Source
Expand description

STCC4 CO2 sensor driver (no-std).

This crate provides a platform agnostic driver for the Sensirion STCC4 CO2 sensor. It supports both blocking and async modes via embedded-hal and embedded-hal-async.

§Features

  • async (default): Enables async support via embedded-hal-async.
  • defmt: Enables defmt::Format derives and adds defmt logging statements.
  • serde: Enables serde support for public data types (no std features).

§Usage (blocking)

use stcc4::blocking::Stcc4;

let mut stcc4 = Stcc4::new(delay, i2c);
stcc4.start_continuous_measurement().ok();
let measurement = stcc4.read_measurement().ok();
stcc4.stop_continuous_measurement().ok();

§Usage (async)

use stcc4::asynchronous::Stcc4;

let mut stcc4 = Stcc4::new(delay, i2c);
stcc4.start_continuous_measurement().await.ok();
let measurement = stcc4.read_measurement().await.ok();
stcc4.stop_continuous_measurement().await.ok();

Modules§

asynchronous
Async API
blocking
Blocking API

Structs§

FrcCorrection
Forced recalibration correction (ppm).
Measurement
Represents a measured sample from the sensor.
ProductId
Product ID and serial number.
SelfTestResult
Self test result (raw word + helpers).
SensorStatus
Sensor status (16-bit word).

Enums§

Stcc4Error
Represents any error that may happen during communication.

Constants§

EXIT_SLEEP_PAYLOAD
Exit sleep payload byte (not acknowledged by the sensor).
I2C_GENERAL_CALL_ADDR
General call I2C address.
SOFT_RESET_CMD
Soft reset command (general call, not acknowledged by the sensor).
STCC4_ADDR_ALT
Alternative I2C address.
STCC4_ADDR_DEFAULT
Default I2C address.