pub struct Sgp30<I2C, D> { /* private fields */ }
Expand description
Driver for the SGP30
Implementations§
source§impl<I2C, D, E> Sgp30<I2C, D>
impl<I2C, D, E> Sgp30<I2C, D>
sourcepub fn serial(&mut self) -> Result<[u8; 6], Error<E>>
pub fn serial(&mut self) -> Result<[u8; 6], Error<E>>
Return the 48 bit serial number of the SGP30.
sourcepub fn selftest(&mut self) -> Result<bool, Error<E>>
pub fn selftest(&mut self) -> Result<bool, Error<E>>
Run an on-chip self-test. Return a boolean indicating whether the test succeeded.
sourcepub fn init(&mut self) -> Result<(), Error<E>>
pub fn init(&mut self) -> Result<(), Error<E>>
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.
sourcepub fn force_init(&mut self) -> Result<(), Error<E>>
pub fn force_init(&mut self) -> Result<(), Error<E>>
Like init()
, but without checking
whether the sensor is already initialized.
This might be necessary after a sensor soft or hard reset.
sourcepub fn measure(&mut self) -> Result<Measurement, Error<E>>
pub fn measure(&mut self) -> Result<Measurement, Error<E>>
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.
sourcepub fn measure_raw_signals(&mut self) -> Result<RawSignals, Error<E>>
pub fn measure_raw_signals(&mut self) -> Result<RawSignals, Error<E>>
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.
sourcepub fn get_baseline(&mut self) -> Result<Baseline, Error<E>>
pub fn get_baseline(&mut self) -> Result<Baseline, Error<E>>
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()
.
sourcepub fn set_baseline(&mut self, baseline: &Baseline) -> Result<(), Error<E>>
pub fn set_baseline(&mut self, baseline: &Baseline) -> Result<(), Error<E>>
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.
sourcepub fn set_humidity(
&mut self,
humidity: Option<&Humidity>
) -> Result<(), Error<E>>
pub fn set_humidity( &mut self, humidity: Option<&Humidity> ) -> Result<(), Error<E>>
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.
sourcepub fn get_feature_set(&mut self) -> Result<FeatureSet, Error<E>>
pub fn get_feature_set(&mut self) -> Result<FeatureSet, Error<E>>
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.