Skip to content

Commit

Permalink
Merge pull request #2 from TeXitoi/add-bmp280
Browse files Browse the repository at this point in the history
Add basic BMP280 support
  • Loading branch information
sbruton authored Aug 21, 2018
2 parents 845e191 + 34f1cc6 commit 5ace7b9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
name = "bme280"
version = "0.1.0"
authors = ["Sean Bruton <[email protected]>"]
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]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
10 changes: 7 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -180,7 +184,7 @@ pub struct Measurements<E> {
pub temperature: f32,
/// pressure in pascals
pub pressure: f32,
/// percent relative humidity
/// percent relative humidity (`0` with BMP280)
pub humidity: f32,
_e: PhantomData<E>,
}
Expand Down Expand Up @@ -342,7 +346,7 @@ where

fn verify_chip_id(&mut self) -> Result<(), Error<E>> {
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)
Expand Down

0 comments on commit 5ace7b9

Please sign in to comment.