pub struct AsyncBme280<I2c, Delay> { /* private fields */ }Expand description
Async interface to BME280 sensor over I²C
Implementations§
Source§impl<I2C, D> Bme280<I2C, D>
impl<I2C, D> Bme280<I2C, D>
Sourcepub fn new(i2c: I2C, delay: D) -> Self
pub fn new(i2c: I2C, delay: D) -> Self
Create a new sensor using an I²C interface and a delay function using
the sensor’s default address DEFAULT_ADDRESS)
Sourcepub fn new_with_address(i2c: I2C, address: u8, delay: D) -> Self
pub fn new_with_address(i2c: I2C, address: u8, delay: D) -> Self
Create a new sensor using an I²C interface and a delay function
Sourcepub async fn init(&mut self) -> Result<(), I2C::Error>
pub async fn init(&mut self) -> Result<(), I2C::Error>
Initialize the sensor
Send a soft-reset signal, obtain the calibration coefficients, and set default sampling configuration.
Note that the default sampling configuration disables measurement of temperature, pressure and humidity.
§Errors
Return an error if it cannot communicate with the sensor.
Sourcepub async fn chip_id(&mut self) -> Result<u8, I2C::Error>
pub async fn chip_id(&mut self) -> Result<u8, I2C::Error>
Obtain the chip id
The chip id is always crate::constants::CHIP_ID, so this function
can be used to validate that communication with the chip works fine.
§Errors
Return an error if it cannot communicate with the sensor.
Sourcepub async fn set_sampling_configuration(
&mut self,
configuration: Configuration,
) -> Result<(), I2C::Error>
pub async fn set_sampling_configuration( &mut self, configuration: Configuration, ) -> Result<(), I2C::Error>
Sourcepub async fn take_forced_measurement(&mut self) -> Result<bool, I2C::Error>
pub async fn take_forced_measurement(&mut self) -> Result<bool, I2C::Error>
Take a forced measurement
When the chip is set to work in forced mode, it goes back to sleep after every measurement. It must be set again to forced mode in order to force a new measurement.
§Errors
Return an error if it cannot communicate with the sensor.
Sourcepub async fn read_sample(&mut self) -> Result<Sample, I2C::Error>
pub async fn read_sample(&mut self) -> Result<Sample, I2C::Error>
Read a sample of temperature, pressure and humidity
Measures that are disabled in the sampling configuration have value
None.
§Errors
Return an error if it cannot communicate with the sensor.
Sourcepub async fn read_temperature(
&mut self,
) -> Result<Option<Temperature>, I2C::Error>
pub async fn read_temperature( &mut self, ) -> Result<Option<Temperature>, I2C::Error>
Read a sample of temperature
If temperature is disabled in the sampling configuration, return None.
§Errors
Return an error if it cannot communicate with the sensor.
Sourcepub async fn read_pressure(&mut self) -> Result<Option<Pressure>, I2C::Error>
pub async fn read_pressure(&mut self) -> Result<Option<Pressure>, I2C::Error>
Read a sample of pressure
The temperature value, necessary to compute the compensated pressure value, is also read from the sensor.
If pressure is disabled in the sampling configuration, return None.
§Errors
Return an error if it cannot communicate with the sensor.
Sourcepub async fn read_pressure_with_temperature(
&mut self,
temperature: f32,
) -> Result<Option<Pressure>, I2C::Error>
pub async fn read_pressure_with_temperature( &mut self, temperature: f32, ) -> Result<Option<Pressure>, I2C::Error>
Read a sample of pressure with a user-specified temperature value
Unlike in Self::read_pressure(), this function does not take the
temperature from the sensor, so it can be used if the temperature
is already known.
If pressure is disabled in the sampling configuration, return None.
§Errors
Return an error if it cannot communicate with the sensor.
Sourcepub async fn read_humidity(&mut self) -> Result<Option<Humidity>, I2C::Error>
pub async fn read_humidity(&mut self) -> Result<Option<Humidity>, I2C::Error>
Read a sample of humidity
The temperature value, necessary to compute the compensated pressure value, is also read from the sensor.
If humidity is disabled in the sampling configuration, return None.
§Errors
Return an error if it cannot communicate with the sensor.
Sourcepub async fn read_humidity_with_temperature(
&mut self,
temperature: f32,
) -> Result<Option<Humidity>, I2C::Error>
pub async fn read_humidity_with_temperature( &mut self, temperature: f32, ) -> Result<Option<Humidity>, I2C::Error>
Read a sample of humidity with a user-specified temperature value
Unlike in Self::read_humidity(), this function does not take the
temperature from the sensor, so it can be used if the temperature
is already known.
If humidity is disabled in the sampling configuration, return None.
§Errors
Return an error if it cannot communicate with the sensor.