no_std driver for the bmp280 (pressure sensor).
- Temperature and pressure readings
- Multiple sensors on the same I2C bus (addresses
0x76and0x77) - Per-sensor calibration data
- Configurable oversampling, filtering, and power modes
BMP280
Include library as a dependency in your Cargo.toml
:
[dependencies.bmp280-ehal]
version = "<version>"
Use an embedded-hal implementation to get an I2C handle, then create a BMP280 driver:
use bmp280_ehal::BMP280;
// Create the driver (auto-calibrates sensor at 0x76 if present):
let mut bmp = BMP280::new(i2c)?;
// Read temperature and pressure from the default sensor:
let temp = bmp.temp(0x76);
let pres = bmp.pressure(0x76);The BMP280 supports two I2C addresses (0x76 and 0x77, selected by the SDO pin).
This driver can manage both through a single instance:
let mut bmp = BMP280::new(i2c)?;
// The constructor auto-calibrates 0x76. Manually calibrate the second sensor:
bmp.read_calibration(0x77);
let temp1 = bmp.temp(0x76);
let temp2 = bmp.temp(0x77);
let pres1 = bmp.pressure(0x76);
let pres2 = bmp.pressure(0x77);For more advanced multi-sensor setups using I2C multiplexers, see docs/multiple-sensor-support.md.
Additional examples can be found in the proving-ground repo.
API Docs available on docs.rs.
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)