pub struct Bme680<I2C, STATE> { /* private fields */ }Expand description
The main BME680 driver structure.
Use Bme680::new(...) to start. The STATE generic uses the Typestate pattern
to track initialization status at compile time.
Implementations§
Source§impl<I2C, E> Bme680<I2C, Uninitialized>where
I2C: I2c<Error = E>,
impl<I2C, E> Bme680<I2C, Uninitialized>where
I2C: I2c<Error = E>,
Sourcepub fn init(self, delay: &mut impl DelayNs) -> Result<Bme680<I2C, Ready>, E>
pub fn init(self, delay: &mut impl DelayNs) -> Result<Bme680<I2C, Ready>, E>
Initializes the sensor: performs a soft-reset and loads factory calibration data.
This transitions the driver state from Uninitialized to Ready.
§Errors
Returns an error if the I2C communication fails during reset or calibration reading.
Source§impl<I2C, E> Bme680<I2C, Ready>where
I2C: I2c<Error = E>,
impl<I2C, E> Bme680<I2C, Ready>where
I2C: I2c<Error = E>,
Sourcepub fn configure_sensor(&mut self, config: &mut Config) -> Result<(), E>
pub fn configure_sensor(&mut self, config: &mut Config) -> Result<(), E>
Applies a full sensor configuration.
This method sets oversampling, filters, and gas profiles.
If config.gas_profile is None, the gas sensor is disabled to save power.
Sourcepub fn set_gas_heater_profile(
&mut self,
config: GasProfile,
amb_temp: Celsius,
) -> Result<(), E>
pub fn set_gas_heater_profile( &mut self, config: GasProfile, amb_temp: Celsius, ) -> Result<(), E>
Configures heating duration and target temperature for a gas profile.
This calculates the necessary register value based on the current ambient temperature.
Sourcepub fn read_new_data(
&mut self,
delay: &mut impl DelayNs,
) -> Result<Measurement, E>
pub fn read_new_data( &mut self, delay: &mut impl DelayNs, ) -> Result<Measurement, E>
Triggers a measurement in ‘Forced Mode’, waits for completion, and returns compensated data.
§Power Saving
If all measurements are set to Skipped and gas is disabled, this function
returns immediately with default values, consuming minimal power.
Sourcepub fn read_chip_id(&mut self) -> Result<u8, E>
pub fn read_chip_id(&mut self) -> Result<u8, E>
Reads the Chip ID from the sensor (expected value: 0x61).
Sourcepub fn select_gas_profile(&mut self, profile: &GasProfile) -> Result<(), E>
pub fn select_gas_profile(&mut self, profile: &GasProfile) -> Result<(), E>
Selects one of the 10 available gas heater profiles.