Struct bme280_multibus::Bme280 [−][src]
pub struct Bme280<B> { /* fields omitted */ }Expand description
BME280 driver.
Implementations
Creates a new Bme280 driver from a SPI peripheral and a chip select
digital I/O pin.
Safety
The chip select pin must be high before being passed to this function.
Example
use bme280_multibus::Bme280;
use embedded_hal::digital::v2::OutputPin;
pin.set_high()?;
let mut bme: Bme280<_> = Bme280::from_spi(spi, pin)?;Create a new BME280 from a spi::Bme280Bus or
a i2c::Bme280Bus.
Example
use bme280_multibus::{
i2c::{Address, Bme280Bus},
Bme280,
};
let mut bus: Bme280Bus<_> = Bme280Bus::new(i2c, Address::SdoGnd);
let bme: Bme280<_> = Bme280::new(bus)?;BME280 chip ID.
The return value is a constant, CHIP_ID.
This register is useful as a sanity check to ensure communications are working with the BME280.
Example
use bme280_multibus::{i2c::Address, Bme280, CHIP_ID};
let mut bme: Bme280<_> = Bme280::from_i2c(i2c, Address::SdoGnd)?;
let chip_id: u8 = bme.chip_id()?;
assert_eq!(chip_id, CHIP_ID);Reset the BME280.
Example
use bme280_multibus::{i2c::Address, Bme280};
let mut bme: Bme280<_> = Bme280::from_i2c(i2c, Address::SdoGnd)?;
bme.reset()?;Get the status of the device.
Example
Check if a conversion is running.
use bme280_multibus::{i2c::Address, Bme280, Status};
let mut bme: Bme280<_> = Bme280::from_i2c(i2c, Address::SdoGnd)?;
let status: Status = bme.status()?;Configure the BME280 settings.
Example
use bme280_multibus::{
i2c::Address, Bme280, Config, CtrlMeas, Filter, Mode, Oversampling, Settings, Standby,
};
const SETTINGS: Settings = Settings {
config: Config::reset()
.set_standby_time(Standby::Millis1000)
.set_filter(Filter::X16),
ctrl_meas: CtrlMeas::reset()
.set_osrs_t(Oversampling::X8)
.set_osrs_p(Oversampling::X8)
.set_mode(Mode::Normal),
ctrl_hum: Oversampling::X8,
};
let mut bme: Bme280<_> = Bme280::from_i2c(i2c, Address::SdoGnd)?;
bme.settings(&SETTINGS)?;Read a sample from the BME280.
Example
use bme280_multibus::{i2c::Address, Bme280, Sample, Standby};
const SETTINGS: bme280_multibus::Settings = bme280_multibus::Settings {
config: bme280_multibus::Config::reset()
.set_standby_time(bme280_multibus::Standby::Millis1000)
.set_filter(bme280_multibus::Filter::X16),
ctrl_meas: bme280_multibus::CtrlMeas::reset()
.set_osrs_t(bme280_multibus::Oversampling::X8)
.set_osrs_p(bme280_multibus::Oversampling::X8)
.set_mode(bme280_multibus::Mode::Normal),
ctrl_hum: bme280_multibus::Oversampling::X8,
};
let mut bme: Bme280<_> = Bme280::from_i2c(i2c, Address::SdoGnd)?;
bme.settings(&SETTINGS)?;
let sample: Sample = bme.sample().unwrap();