Expand description

A platform agnostic Rust driver for the Bosch BME280 and BMP280, based on the embedded-hal traits.

The Device

The Bosch BME280 is a highly accurate sensor for atmospheric temperature, pressure, and relative humidity.

The Bosch BMP280 is a highly accurate sensor for atmospheric temperature, and pressure.

The device has I²C and SPI interfaces.

Usage

use linux_embedded_hal::{Delay, I2cdev};
use bme280::i2c::BME280;

// using Linux I2C Bus #1 in this example
let i2c_bus = I2cdev::new("/dev/i2c-1").unwrap();

// initialize the BME280 using the primary I2C address 0x76
let mut bme280 = BME280::new_primary(i2c_bus, Delay);

// or, initialize the BME280 using the secondary I2C address 0x77
// let mut bme280 = BME280::new_secondary(i2c_bus, Delay);

// or, initialize the BME280 using a custom I2C address
// let bme280_i2c_addr = 0x88;
// let mut bme280 = BME280::new(i2c_bus, bme280_i2c_addr, Delay);

// initialize the sensor
bme280.init().unwrap();

// measure temperature, pressure, and humidity
let measurements = bme280.measure().unwrap();

println!("Relative Humidity = {}%", measurements.humidity);
println!("Temperature = {} deg C", measurements.temperature);
println!("Pressure = {} pascals", measurements.pressure);

Modules

BME280 driver for sensors attached via I2C.

BME280 driver for sensors attached via SPI.

Structs

Measurement data

Enums

BME280 errors

BME280 operating mode