Crate sen66_interface

Source
Expand description

§SEN66 Driver

Crates.io Version docs.rs Integration Pipeline codecov Crates.io MSRV

A driver for interacting with Sensirion’s SEN66 environment sensing platform via I2C. The driver is based on the embedded-hal traits and offers a synchronous and asynchronous interface.

Provides a full implementation of the SEN66 features:

  • Measure environment parameters:
    • Mass concentrations PM1.0, PM2.5, PM4.0, PM10.0 in ug/m³
    • Number concentrations PM0.5, PM1.0, PM2.5, PM4.0, PM10.0 in p/cm³
    • Ambient relative humidity in %
    • Ambient temperature in °C
    • VOC Index around 100
    • NOx Index around 1
    • Raw VOC ticks
    • Raw NOx ticks
    • CO2 in ppm
  • Configure VOC, NOx, CO2 and Temperature determination
  • Perform forced CO2 recalibration, SHT heating and fan cleaning
  • Read out device information
    • Serial Number
    • Product Name
    • Device Status

§Example

This example showcases how to use the SEN66 with a ESP32-C6-DevKitM-1 using embassy.

use sen66_interface::asynch::Sen66;

#[esp_hal_embassy::main]
async fn main(spawner: Spawner) {
    let config = esp_hal::Config::default().with_cpu_clock(CpuClock::max());
    let peripherals = esp_hal::init(config);

    let timer0 = esp_hal::timer::systimer::SystemTimer::new(peripherals.SYSTIMER);
    esp_hal_embassy::init(timer0.alarm0);

    let i2c = esp_hal::i2c::master::I2c::new(
        peripherals.I2C0,
        esp_hal::i2c::master::Config::default()
        ).unwrap()
        .into_async()
        .with_sda(peripherals.GPIO22)
        .with_scl(peripherals.GPIO23);

    let mut sensor = Sen66::new(embassy_time::Delay, i2c);

    // Provide enough time to start up after power-on
    embassy_time::Timer::after(embassy_time::Duration::from_millis(100)).await;

    sensor.get_product_name().await.unwrap()
}

§Feature Flags

  • async: Provides an async interface, enabled by default.
  • blocking: Provides a blocking interface.
  • defmt: Provides support for defmt.

§Contributing

If you want to contribute, open a Pull Request with your suggested changes and ensure that the integration pipeline runs.

§License

Licensed under either of

SPDX-License-Identifier: Apache-2.0 OR MIT

Modules§

asynch
Async interface for the SEN66 Implementation of the SCD30’s interface
command
SEN66 I2C Commands.
configuration
Data types for configuring the SEN66’s operations.
data
Data types for configuring the SEN66’s operations.
error
Errors emitted by this library.