Struct AsyncScd4x

Source
pub struct AsyncScd4x<I2c, Delay, State> { /* private fields */ }
Expand description

Interface to SCD4x sensor over I²C

Implementations§

Source§

impl<I2C, D> Scd4x<I2C, D, Idle>
where I2C: I2c, D: DelayNs,

Source

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

Create a new sensor using an I²C interface and a delay function using the sensor’s default address DEFAULT_ADDRESS)

Source

pub fn new_with_address(i2c: I2C, address: u8, delay: D) -> Self

Create a new sensor using an I²C interface and a delay function using a custom address

Source

pub async fn start_periodic_measurement( self, ) -> Result<Scd4x<I2C, D, Measuring>, Error>

Start periodic measurement

§Errors

Return an error if it cannot communicate with the sensor.

Source

pub async fn set_temperature_offset( &mut self, temperature_offset: Temperature, ) -> Result<(), Error>

Set temperature offset

§Errors

Return an error if it cannot communicate with the sensor.

Source

pub async fn get_temperature_offset(&mut self) -> Result<Temperature, Error>

Get temperature offset

§Errors

Return an error if it cannot communicate with the sensor.

Source

pub async fn set_sensor_altitude( &mut self, sensor_altitude: Altitude, ) -> Result<(), Error>

Set sensor altitude

§Errors

Return an error if it cannot communicate with the sensor.

Source

pub async fn get_sensor_altitude(&mut self) -> Result<Altitude, Error>

Get sensor altitude

§Errors

Return an error if it cannot communicate with the sensor.

Source

pub async fn perform_forced_recalibration( &mut self, co2: Co2, ) -> Result<Option<Co2>, Error>

Perform forced recalibration

§Errors

Return an error if it cannot communicate with the sensor.

Source

pub async fn set_automatic_self_calibration_enabled( &mut self, enabled: bool, ) -> Result<(), Error>

Set whether automatic self-calibration is enabled

§Errors

Return an error if it cannot communicate with the sensor.

Source

pub async fn get_automatic_self_calibration_enabled( &mut self, ) -> Result<bool, Error>

Query whether automatic self-calibration is enabled

§Errors

Return an error if it cannot communicate with the sensor.

Source

pub async fn start_low_power_periodic_measurement( self, ) -> Result<Scd4x<I2C, D, Measuring>, Error>

Start low-power periodic measurement

§Errors

Return an error if it cannot communicate with the sensor.

Source

pub async fn persist_settings(&mut self) -> Result<(), Error>

Persist settings to EEPROM

§Errors

Return an error if it cannot communicate with the sensor.

Source

pub async fn get_serial_number(&mut self) -> Result<u64, Error>

Obtain the serial number

§Errors

Return an error if it cannot communicate with the sensor.

Source

pub async fn perform_self_test(&mut self) -> Result<bool, Error>

Perform self-test

§Errors

Return an error if it cannot communicate with the sensor.

Source

pub async fn perform_factory_reset(&mut self) -> Result<(), Error>

Perform factory reset

§Errors

Return an error if it cannot communicate with the sensor.

Source

pub async fn reinit(&mut self) -> Result<(), Error>

Reinitialize the sensor

Send a soft-reset signal, obtain the calibration coefficients, and set default sampling configuration.

Note that the default sampling configuration disables measurement of temperature, pressure and humidity.

§Errors

Return an error if it cannot communicate with the sensor.

Source

pub async fn measure_single_shot( self, ) -> Result<Scd4x<I2C, D, Measuring>, Error>

Read a single-shot measurement

§Errors

Return an error if it cannot communicate with the sensor.

Source

pub async fn measure_single_shot_rht_only( self, ) -> Result<Scd4x<I2C, D, Measuring>, Error>

Read a single-shot measurement of humidity and temperature

§Errors

Return an error if it cannot communicate with the sensor.

Source§

impl<I2C, D> Scd4x<I2C, D, Measuring>
where I2C: I2c, D: DelayNs,

Source

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

Create a new sensor in measuring state using an I²C interface and a delay function using the sensor’s default address DEFAULT_ADDRESS)

Source

pub fn new_in_measuring_with_address(i2c: I2C, address: u8, delay: D) -> Self

Create a new sensor in measuring state using an I²C interface and a delay function

Source

pub async fn read_measurement(&mut self) -> Result<Sample, Error>

Read a measurement from the sensor

§Errors

Return an error if it cannot communicate with the sensor.

Source

pub async fn get_data_ready_status(&mut self) -> Result<bool, Error>

Query whether data is available to be read

§Errors

Return an error if it cannot communicate with the sensor.

Source§

impl<I2C, D, S> Scd4x<I2C, D, S>
where I2C: I2c, D: DelayNs, S: State,

Source

pub fn release(self) -> I2C

Release the I²C interface

Source

pub async fn stop_periodic_measurement( self, ) -> Result<Scd4x<I2C, D, Idle>, Error>

Stop periodic measurement

§Errors

Return an error if it cannot communicate with the sensor.

Source

pub async fn set_ambient_pressure( &mut self, ambient_pressure: Pressure, ) -> Result<(), Error>

Set ambient pressure

§Errors

Return an error if it cannot communicate with the sensor.

Auto Trait Implementations§

§

impl<I2c, Delay, State> Freeze for Scd4x<I2c, Delay, State>
where I2c: Freeze, Delay: Freeze,

§

impl<I2c, Delay, State> RefUnwindSafe for Scd4x<I2c, Delay, State>
where I2c: RefUnwindSafe, Delay: RefUnwindSafe, State: RefUnwindSafe,

§

impl<I2c, Delay, State> Send for Scd4x<I2c, Delay, State>
where I2c: Send, Delay: Send, State: Send,

§

impl<I2c, Delay, State> Sync for Scd4x<I2c, Delay, State>
where I2c: Sync, Delay: Sync, State: Sync,

§

impl<I2c, Delay, State> Unpin for Scd4x<I2c, Delay, State>
where I2c: Unpin, Delay: Unpin, State: Unpin,

§

impl<I2c, Delay, State> UnwindSafe for Scd4x<I2c, Delay, State>
where I2c: UnwindSafe, Delay: UnwindSafe, State: 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.