#temperature-humidity #pressure-sensor #humidity-sensor #pressure #temperature #humidity #bmp280

no-std bme280

A rust device driver for the Bosch BME280 temperature, humidity, and atmospheric pressure sensor and the Bosch BMP280 temperature, and atmospheric pressure sensor

9 unstable releases

new 0.5.1 Apr 20, 2024
0.5.0 Jan 29, 2024
0.4.4 Jun 4, 2022
0.3.0 Mar 31, 2022
0.1.0 Jun 15, 2018

#71 in Embedded development

Download history 13/week @ 2024-01-03 27/week @ 2024-01-10 20/week @ 2024-01-17 38/week @ 2024-01-24 9/week @ 2024-01-31 15/week @ 2024-02-07 44/week @ 2024-02-14 143/week @ 2024-02-21 56/week @ 2024-02-28 44/week @ 2024-03-06 43/week @ 2024-03-13 37/week @ 2024-03-20 85/week @ 2024-03-27 165/week @ 2024-04-03 48/week @ 2024-04-10 253/week @ 2024-04-17

554 downloads per month

MIT/Apache

45KB
1K SLoC

bme280

Crates.io Crates.io Released API docs

A rust device driver for the Bosch BME280 temperature, humidity, and atmospheric pressure sensor and the Bosch BMP280 temperature and atmospheric pressure sensor.

Usage

use linux_embedded_hal as hal;

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();
let mut delay = /* ..delay provider */
// initialize the BME280 using the primary I2C address 0x76
let mut bme280 = BME280::new_primary(i2c_bus);

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

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

// initialize the sensor
bme280.init(&mut delay).unwrap();

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

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

Serde Support

To enable optional serde serialization support for the measurements struct, simply enable the serde feature, like so in Cargo.toml:

[dependencies]
bme280 = { version = "0.2", features = ["serde"] }

License

Licensed under either of:

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~2.5MB
~57K SLoC