pub struct Sgp30<I2C, D> { /* private fields */ }Expand description
SGP30 device driver
Implementations§
Source§impl<I2C, D> Sgp30<I2C, D>
impl<I2C, D> Sgp30<I2C, D>
Sourcepub fn get_baseline(&mut self) -> Result<AirQuality, Error<I2C::Error>>
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.
Sourcepub fn initialize_air_quality_measure(
&mut self,
) -> Result<(), Error<I2C::Error>>
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().
Sourcepub fn measure_air_quality(&mut self) -> Result<AirQuality, Error<I2C::Error>>
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.
Sourcepub fn measure_raw_signals(&mut self) -> Result<RawSignals, Error<I2C::Error>>
pub fn measure_raw_signals(&mut self) -> Result<RawSignals, Error<I2C::Error>>
Measure the raw signals (H₂ and ethanol).
Itreturns the raw signals of the sensor.
Sourcepub fn new(
i2c: I2C,
address: SevenBitAddress,
delay: D,
) -> Result<Self, Error<I2C::Error>>
pub fn new( i2c: I2C, address: SevenBitAddress, delay: D, ) -> Result<Self, Error<I2C::Error>>
Create a new instance of the SGP30 device.
Sourcepub fn set_baseline(
&mut self,
baseline: AirQuality,
) -> Result<(), Error<I2C::Error>>
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().
Sourcepub fn set_humidity(&mut self, humidity: f32) -> Result<(), Error<I2C::Error>>
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.