Crate sen6x

Source
Expand description

This crate provides a platform agnostic no_std driver for the SEN6X sensor modules. The driver is compatible with the embedded-hal traits.

The data sheet of the sensor modules can be found here.

§Supported Features by Sensor Variant (Blocking & Async)

Both blocking and async modes are implemented for the following functionality.

FunctionalitySEN63CSEN65SEN66SEN68
Start/stop measurement
Get data ready status
Read measured values
Read raw measured values
Read number concentration values
Set temperature offset parameters
Set temperature acceleration
Get product name
Get serial number
Read/clear device status
Device reset
Fan cleaning
Activate SHT heater
VOC algorithm tuning parameters
VOC algorithm state
NOx algorithm tuning parameters
Forced CO2 recalibration
CO2 sensor auto calibration
Set/get ambient pressure
Set/get sensor altitude

§Sensor Measurements by Variant

MeasurementSEN63CSEN65SEN66SEN68
PM1.0 (µg/m³)
PM2.5 (µg/m³)
PM4.0 (µg/m³)
PM10 (µg/m³)
Humidity (%)
Temperature (°C)
CO2 (ppm)
VOC (index points)
NOx (index points)
HCHO (ppb)

§Raw Measurements by Variant

Raw MeasurementSEN63CSEN65SEN66SEN68
Raw humidity
Raw temperature
Raw VOC ticks
Raw NOx ticks
Raw CO2

§Supported sensor variants

This generated documentation covers the SEN66 variant (default feature). For any other variant, please consult the source code. The same functions should be available (if the variant supports that functionality), but the sample data returned will contain different characteristics.
  • SEN63C (crate feature sen63c)
  • SEN65 (crate feature sen65)
  • SEN66 (crate feature sen66, default)
  • SEN68 (crate feature sen68)

The sensor variants are mutually exclusive. Only one sensor variant feature can be enabled at a time. To activate a sensor variant other than the default SEN66, disable the default feature and enable the desired sensor variant feature.

§Currently unsupported sensor variants

  • SEN60 (substantially different command set)

§Rust Features

  • async (default): Enables async support portion of the driver
  • defmt: Enables the defmt::Format trait for the defmt logging framework (adds defmt crate as dependency)
  • serde: Enables serde support for the driver (adds serde crate as dependency, with default features disabled for no-std compatibility)
  • std: Enables std functionality of the driver (unlocks thiserror error macros)
  • sen60/sen63/sen65/sen66 (default) /sen68: Enables support for the respective sensor variant. Only one of these features can be enabled at a time. The variant enabled by default is sen66.

§Usage

By default, the driver is in blocking mode. To access the async mode variant, enable the async feature.

The documentation and examples of both modes can be found in the respective modules blocking and async.

§Unit tests

To run the extensive unit tests, use the following command:

cargo xtask test-features

Modules§

asynchronous
Async API
blocking
Blocking API

Structs§

AlgorithmTuningParameters
VOC/NOx algorithm tuning parameters
DeviceStatus
MeasuredSample
Represents a measured sample from the sensor module.
RawConcentrationSample
Represents a concentration sample from the sensor module. (these are the same values as in the MeasuredSample struct, just not scaled to the correct values)
RawMeasuredSample
Represents a raw measured sample from the sensor module.
TempAccelPars
(Volatile) internal temperature acceleration parameters
TempOffsetPars
(Volatile) internal temperature offset parameters

Enums§

Sen6xError
Represents any error that may happen during communication.