Sgp30

Struct Sgp30 

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

SGP30 device driver

Implementations§

Source§

impl<I2C, D> Sgp30<I2C, D>
where I2C: I2c, D: DelayNs,

Source

pub fn get_baseline(&mut self) -> Result<AirQuality, Error<I2C::Error>>

Get the baseline values for the air quality signals.

The goal of this feature is to save the baseline at regular intervals on an external non-volatile memory and be able to restore these values after a new power-up or a soft reset of the sensor.

See Sgp30::set_baseline() for instructions on how to restore the values that have been saved here.

Source

pub fn initialize_air_quality_measure( &mut self, ) -> Result<(), Error<I2C::Error>>

Start the air quality measurement

After this function has been called, the Sgp30::measure_air_quality() function has to be called at regular intervals of 1s to ensure the proper operation of the dynamic baseline compensation algorithm. This has to be called after every power-up or after each soft reset performed with Sgp30::reset().

Source

pub fn measure_air_quality(&mut self) -> Result<AirQuality, Error<I2C::Error>>

Measure the air quality (CO₂eq and TVOC).

This function has to be called at regular invervals of 1s after the air quality measure has been initialized with Sgp30::initialize_air_quality_measure(), to ensure the proper operation of the dynamic baseline compensation algorithm.

For the first 15s after the initialization, the sensor is in an initialization phase and this function will return an air quality measure with fixed values of 400 ppm CO₂eq and 0 ppb TVOC.

Source

pub fn measure_raw_signals(&mut self) -> Result<RawSignals, Error<I2C::Error>>

Measure the raw signals (H₂ and ethanol).

This is intended for part verification and testing purposes, therefore you should not need it.

Itreturns the raw signals of the sensor.

Source

pub fn new( i2c: I2C, address: SevenBitAddress, delay: D, ) -> Result<Self, Error<I2C::Error>>

Create a new instance of the SGP30 device.

Source

pub fn reset(&mut self) -> Result<(), Error<I2C::Error>>

Perform a soft reset.

Source

pub fn set_baseline( &mut self, baseline: AirQuality, ) -> Result<(), Error<I2C::Error>>

Set the baseline values for the air quality signals.

The goal of this feature is to feed the baseline correction algorithm with values that have been stored on an external memory using the Sgp30::get_baseline() function.

This needs to be called just after calling Sgp30::initialize_air_quality_measure(), and prior to any call to Sgp30::measure_air_quality().

Source

pub fn set_humidity(&mut self, humidity: f32) -> Result<(), Error<I2C::Error>>

Feed the on-chip humidity compensation algorithm with the current humidity to get more accurate air quality measurements.

The given humidity is the absolute humidity in g/m³, that needs to be measured with an external sensor such as the SHT3x.

This feature may not be available depending on the version of your sensor.

Trait Implementations§

Source§

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

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

impl<I2C, D> UnwindSafe for Sgp30<I2C, D>
where D: UnwindSafe, I2C: 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.