[][src]Struct sgp30::Sgp30

pub struct Sgp30<I2C, D> { /* fields omitted */ }

Driver for the SGP30

Implementations

impl<I2C, D, E> Sgp30<I2C, D> where
    I2C: Read<Error = E> + Write<Error = E> + WriteRead<Error = E>,
    D: DelayUs<u16> + DelayMs<u16>, 
[src]

pub fn new(i2c: I2C, address: u8, delay: D) -> Self[src]

Create a new instance of the SGP30 driver.

pub fn destroy(self) -> I2C[src]

Destroy driver instance, return I²C bus instance.

pub fn serial(&mut self) -> Result<[u8; 6], Error<E>>[src]

Return the 48 bit serial number of the SGP30.

pub fn selftest(&mut self) -> Result<bool, Error<E>>[src]

Run an on-chip self-test. Return a boolean indicating whether the test succeeded.

pub fn init(&mut self) -> Result<(), Error<E>>[src]

Initialize the air quality measurement.

The SGP30 uses a dynamic baseline compensation algorithm and on-chip calibration parameters to provide two complementary air quality signals.

Calling this method starts the air quality measurement. After initializing the measurement, the measure() method must be called in regular intervals of 1 s to ensure proper operation of the dynamic baseline compensation algorithm. It is the responsibility of the user of this driver to ensure that these periodic measurements are being done.

For the first 15 s after initializing the air quality measurement, the sensor is in an initialization phase during which it returns fixed values of 400 ppm CO₂eq and 0 ppb TVOC. After 15 s (15 measurements) the values should start to change.

A new init command has to be sent after every power-up or soft reset.

pub fn force_init(&mut self) -> Result<(), Error<E>>[src]

Like init(), but without checking whether the sensor is already initialized.

This might be necessary after a sensor soft or hard reset.

pub fn measure(&mut self) -> Result<Measurement, Error<E>>[src]

Get an air quality measurement.

Before calling this method, the air quality measurements must have been initialized using the init() method. Otherwise an Error::NotInitialized will be returned.

Once the measurements have been initialized, the measure() method must be called in regular intervals of 1 s to ensure proper operation of the dynamic baseline compensation algorithm. It is the responsibility of the user of this driver to ensure that these periodic measurements are being done.

For the first 15 s after initializing the air quality measurement, the sensor is in an initialization phase during which it returns fixed values of 400 ppm CO₂eq and 0 ppb TVOC. After 15 s (15 measurements) the values should start to change.

pub fn measure_raw_signals(&mut self) -> Result<RawSignals, Error<E>>[src]

Return sensor raw signals.

This command is intended for part verification and testing purposes. It returns the raw signals which are used as inputs for the on-chip calibration and baseline compensation algorithm. The command performs a measurement to which the sensor responds with the two signals for H2 and Ethanol.

pub fn get_baseline(&mut self) -> Result<Baseline, Error<E>>[src]

Return the baseline values of the baseline correction algorithm.

The SGP30 provides the possibility to read and write the baseline values of the baseline correction algorithm. This feature is used to save the baseline in regular intervals on an external non-volatile memory and restore it after a new power-up or soft reset of the sensor.

This function returns the baseline values for the two air quality signals. These two values should be stored on an external memory. After a power-up or soft reset, the baseline of the baseline correction algorithm can be restored by calling init() followed by set_baseline().

pub fn set_baseline(&mut self, baseline: &Baseline) -> Result<(), Error<E>>[src]

Set the baseline values for the baseline correction algorithm.

Before calling this method, the air quality measurements must have been initialized using the init() method. Otherwise an Error::NotInitialized will be returned.

The SGP30 provides the possibility to read and write the baseline values of the baseline correction algorithm. This feature is used to save the baseline in regular intervals on an external non-volatile memory and restore it after a new power-up or soft reset of the sensor.

This function sets the baseline values for the two air quality signals.

pub fn set_humidity(
    &mut self,
    humidity: Option<&Humidity>
) -> Result<(), Error<E>>
[src]

Set the humidity value for the baseline correction algorithm.

The SGP30 features an on-chip humidity compensation for the air quality signals (CO₂eq and TVOC) and sensor raw signals (H2 and Ethanol). To use the on-chip humidity compensation, an absolute humidity value from an external humidity sensor is required.

After setting a new humidity value, this value will be used by the on-chip humidity compensation algorithm until a new humidity value is set. Restarting the sensor (power-on or soft reset) or calling the function with a None value sets the humidity value used for compensation to its default value (11.57 g/m³) until a new humidity value is sent.

Before calling this method, the air quality measurements must have been initialized using the init() method. Otherwise an Error::NotInitialized will be returned.

pub fn get_feature_set(&mut self) -> Result<FeatureSet, Error<E>>[src]

Get the feature set.

The SGP30 features a versioning system for the available set of measurement commands and on-chip algorithms. This so called feature set version number can be read out with this method.

Trait Implementations

impl<I2C: Debug, D: Debug> Debug for Sgp30<I2C, D>[src]

impl<I2C: Default, D: Default> Default for Sgp30<I2C, D>[src]

Auto Trait Implementations

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

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.