sen5x 0.2.0

Rust driver for the Sensirion SEN5x series. All-in-one sensor solution platform for the accurate measurement of various environmental parameters, such as particulate matter, volatile organic compounds (VOCs), oxidizing gases, such as nitrogen oxide compounds (NOx), as well as humidity & temperature
Documentation

Sensirion I2C SEN5x Driver

Crates.io Docs.rs License no_std

A platform-agnostic no_std Rust driver for the Sensirion SEN5x series (SEN50/SEN54/SEN55), built on embedded-hal traits. Based on embedded-i2c-sen5x and sgpc3-rs.

Sensirion SEN5x

The SEN5x is an all-in-one sensor solution platform for the accurate measurement of various environmental parameters, such as particulate matter, volatile organic compounds (VOCs), oxidizing gases, such as nitrogen oxide compounds (NOx), as well as humidity & temperature.

  • SEN50: Particulate matter only
  • SEN54: PM + VOC + humidity + temperature
  • SEN55: PM + VOC + NOx + humidity + temperature

Further information: Datasheet Environmental Node SEN5x

Features

  • Full SEN5x command set (measurement control, fan cleaning, device info, status)
  • Temperature compensation parameters (offset, slope, time constant)
  • VOC/NOx algorithm tuning and state backup/restore
  • Fan auto cleaning interval configuration
  • RH/T acceleration mode
  • Async support via the embedded-hal-async feature
  • Optional defmt support for embedded logging
  • Optional thiserror integration for std environments

Usage

Add to your Cargo.toml:

[dependencies]
sen5x = "0.1"

# For async support:
# sen5x = { version = "0.1", features = ["embedded-hal-async"] }

Blocking Example

use sen5x::Sen5x;

let mut sensor = Sen5x::new(i2c, delay);

sensor.device_reset()?;
delay.delay_ms(200);

let serial = sensor.serial_number()?;
let version = sensor.version()?;

sensor.start_measurement()?;

loop {
    delay.delay_ms(1000);
    if sensor.data_ready()? {
        let data = sensor.measurement()?;
        // data.mass_concentration_pm2p5, data.ambient_temperature, etc.
    }
}

Async Example

use sen5x::Sen5xAsync;

let mut sensor = Sen5xAsync::new(i2c, delay);

sensor.start_measurement().await?;

loop {
    delay.delay_ms(1000).await;
    if sensor.data_ready().await? {
        let data = sensor.measurement().await?;
    }
}

Full Examples

License

Licensed under either of

Contributing

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.