Skip to main content

Sen5x

Struct Sen5x 

Source
pub struct Sen5x<I2C, D> { /* private fields */ }
Expand description

SEN5x sensor instance. Use related methods to take measurements.

Implementations§

Source§

impl<I2C, D, E> Sen5x<I2C, D>
where I2C: I2c<Error = E>, D: DelayNs,

Source

pub fn new(i2c: I2C, delay: D) -> Self

Create a new SEN5x driver instance.

Source

pub fn destroy(self) -> I2C

Destroy the driver and return the I2C bus.

Source

pub fn start_measurement(&mut self) -> Result<(), Error<E>>

Start periodic measurement, signal update interval is 1 second.

Source

pub fn start_measurement_without_pm(&mut self) -> Result<(), Error<E>>

Start periodic measurement without PM (low-power mode, RH/T/VOC/NOx only).

Source

pub fn stop_measurement(&mut self) -> Result<(), Error<E>>

Stop periodic measurement and return to idle mode.

Source

pub fn data_ready(&mut self) -> Result<bool, Error<E>>

Check whether new measurement data is available for read-out.

Source

pub fn measurement(&mut self) -> Result<SensorData, Error<E>>

Read converted sensor data (f32 scaled values).

Source

pub fn read_measured_values_as_integers( &mut self, ) -> Result<RawSensorData, Error<E>>

Read measured values as raw integer ticks.

Source

pub fn read_measured_raw_values( &mut self, ) -> Result<RawMeasurementValues, Error<E>>

Read measured raw sensor ticks (unscaled humidity, temperature, VOC, NOx).

Source

pub fn read_measured_pm_values(&mut self) -> Result<PmValues, Error<E>>

Read extended PM values including number concentrations and typical particle size.

Source

pub fn start_fan_cleaning(&mut self) -> Result<(), Error<E>>

Start fan cleaning manually. Only available during measurement with PM.

Source

pub fn fan_auto_cleaning_interval(&mut self) -> Result<u32, Error<E>>

Get fan auto cleaning interval in seconds. 0 means auto cleaning is disabled.

Source

pub fn set_fan_auto_cleaning_interval( &mut self, seconds: u32, ) -> Result<(), Error<E>>

Set fan auto cleaning interval in seconds. Set to 0 to disable auto cleaning.

Source

pub fn temperature_offset_parameters( &mut self, ) -> Result<TemperatureOffsetParameters, Error<E>>

Get temperature compensation parameters.

Source

pub fn set_temperature_offset_parameters( &mut self, params: &TemperatureOffsetParameters, ) -> Result<(), Error<E>>

Set temperature compensation parameters (offset, slope, time constant).

Source

pub fn set_temperature_offset_simple( &mut self, temp_offset: f32, ) -> Result<(), Error<E>>

Set a simple temperature offset in °C (slope=0, time_constant=0).

Source

pub fn warm_start_parameter(&mut self) -> Result<u16, Error<E>>

Get warm start parameter.

Source

pub fn set_warm_start_parameter( &mut self, warm_start: u16, ) -> Result<(), Error<E>>

Set warm start parameter (0–65535). Applied at next measurement start.

Source

pub fn voc_algorithm_tuning( &mut self, ) -> Result<AlgorithmTuningParameters, Error<E>>

Get VOC algorithm tuning parameters.

Source

pub fn set_voc_algorithm_tuning( &mut self, params: &AlgorithmTuningParameters, ) -> Result<(), Error<E>>

Set VOC algorithm tuning parameters.

Source

pub fn nox_algorithm_tuning( &mut self, ) -> Result<AlgorithmTuningParameters, Error<E>>

Get NOx algorithm tuning parameters (SEN55 only).

Source

pub fn set_nox_algorithm_tuning( &mut self, params: &AlgorithmTuningParameters, ) -> Result<(), Error<E>>

Set NOx algorithm tuning parameters (SEN55 only).

Source

pub fn rht_acceleration_mode(&mut self) -> Result<u16, Error<E>>

Get RH/T acceleration mode.

Source

pub fn set_rht_acceleration_mode(&mut self, mode: u16) -> Result<(), Error<E>>

Set RH/T acceleration mode. Applied at next measurement start.

Source

pub fn voc_algorithm_state(&mut self) -> Result<[u16; 4], Error<E>>

Get VOC algorithm state for backup (8 bytes as 4 u16 words).

Source

pub fn set_voc_algorithm_state( &mut self, state: &[u16; 4], ) -> Result<(), Error<E>>

Set VOC algorithm state for warm start after power cycle.

Source

pub fn product_name(&mut self) -> Result<[u8; 32], Error<E>>

Get product name as ASCII bytes (null-terminated).

Source

pub fn serial_number(&mut self) -> Result<[u8; 32], Error<E>>

Get serial number as ASCII bytes (null-terminated).

Source

pub fn version(&mut self) -> Result<VersionInfo, Error<E>>

Get firmware, hardware, and protocol version information.

Source

pub fn device_status(&mut self) -> Result<u32, Error<E>>

Read device status register.

Source

pub fn read_and_clear_device_status(&mut self) -> Result<u32, Error<E>>

Read and clear device status register.

Source

pub fn device_reset(&mut self) -> Result<(), Error<E>>

Reset the sensor (equivalent to power cycle).

Trait Implementations§

Source§

impl<I2C: Debug, D: Debug> Debug for Sen5x<I2C, D>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<I2C: Default, D: Default> Default for Sen5x<I2C, D>

Source§

fn default() -> Sen5x<I2C, D>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<I2C, D> Freeze for Sen5x<I2C, D>
where I2C: Freeze, D: Freeze,

§

impl<I2C, D> RefUnwindSafe for Sen5x<I2C, D>

§

impl<I2C, D> Send for Sen5x<I2C, D>
where I2C: Send, D: Send,

§

impl<I2C, D> Sync for Sen5x<I2C, D>
where I2C: Sync, D: Sync,

§

impl<I2C, D> Unpin for Sen5x<I2C, D>
where I2C: Unpin, D: Unpin,

§

impl<I2C, D> UnsafeUnpin for Sen5x<I2C, D>
where I2C: UnsafeUnpin, D: UnsafeUnpin,

§

impl<I2C, D> UnwindSafe for Sen5x<I2C, D>
where I2C: UnwindSafe, D: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.