diff --git a/Cargo.toml b/Cargo.toml index 121e21f..be93d01 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,10 +2,10 @@ name = "bme280" version = "0.1.0" authors = ["Sean Bruton "] -description = "A rust device driver for the Bosch BME280 temperature, humidity, and atmospheric pressure sensor" +description = "A rust device driver for the Bosch BME280 temperature, humidity, and atmospheric pressure sensor and the Bosch BMP280 temperature, and atmospheric pressure sensor" repository = "https://github.com/uber-foo/bme280-rs" license = "MIT OR Apache-2.0" -keywords = ["bme280", "temperature", "pressure", "humidity"] +keywords = ["bme280", "bmp280", "temperature", "pressure", "humidity"] categories = ["embedded", "no-std", "hardware-support"] [dependencies] diff --git a/README.md b/README.md index 6e88f54..3843675 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # bme280 -A rust device driver for the Bosch BME280 temperature, humidity, and atmospheric pressure sensor. +A rust device driver for the Bosch BME280 temperature, humidity, and atmospheric pressure sensor and the Bosch BMP280 temperature and atmospheric pressure sensor. WARNING: This library is under active development. It is not currently intended for production use. diff --git a/src/lib.rs b/src/lib.rs index 227da21..44aa7e0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,7 +8,7 @@ )] #![no_std] -//! A platform agnostic Rust driver for the Bosch BME280, based on the +//! A platform agnostic Rust driver for the Bosch BME280 and BMP280, based on the //! [`embedded-hal`](https://github.com/japaric/embedded-hal) traits. //! //! ## The Device @@ -17,6 +17,9 @@ //! is a highly accurate sensor for atmospheric temperature, pressure, and //! relative humidity. //! +//! The [Bosch BMP280](https://www.bosch-sensortec.com/bst/products/all_products/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 @@ -70,6 +73,7 @@ const BME280_RESET_ADDR: u8 = 0xE0; const BME280_SOFT_RESET_CMD: u8 = 0xB6; const BME280_CHIP_ID: u8 = 0x60; +const BMP280_CHIP_ID: u8 = 0x58; const BME280_CHIP_ID_ADDR: u8 = 0xD0; const BME280_DATA_ADDR: u8 = 0xF7; @@ -180,7 +184,7 @@ pub struct Measurements { pub temperature: f32, /// pressure in pascals pub pressure: f32, - /// percent relative humidity + /// percent relative humidity (`0` with BMP280) pub humidity: f32, _e: PhantomData, } @@ -342,7 +346,7 @@ where fn verify_chip_id(&mut self) -> Result<(), Error> { let chip_id = self.read_register(BME280_CHIP_ID_ADDR)?; - if chip_id == BME280_CHIP_ID { + if chip_id == BME280_CHIP_ID || chip_id == BMP280_CHIP_ID { Ok(()) } else { Err(Error::UnsupportedChip)