Crate bme280

Source
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§

i2c
BME280 driver for sensors attached via I2C.
spi
BME280 driver for sensors attached via SPI.

Structs§

Configuration
Configuration values for the BME280 sensor. The default sets all oversampling settings to 1x and disables the IIR filter.
Measurements
Measurement data

Enums§

Error
BME280 errors
IIRFilter
Lowpass filter settings for pressure and temperature values. See section 3.4.4 of the datasheet for more information on this. The default setting is disabled.
Oversampling
Oversampling settings for temperature, pressure, and humidity measurements. See sections 3.4ff of the manual for measurement flow and recommended values. The default is 1x, i.e., no oversampling.
SensorMode
BME280 operating mode