Crate bme280[][src]

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 (SPI is not currently supported).

Usage

extern crate linux_embedded_hal as hal;
extern crate bme280;

use hal::{Delay, I2cdev};
use bme280::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 0x77
let mut bme280 = BME280::new_primary(i2c_bus, Delay);

// or, initialize the BME280 using the secondary I2C address 0x78
// 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);

Structs

BME280

Representation of a BME280

Measurements

Measurement data

Enums

Error

BME280 errors

SensorMode

BME280 operating mode