Crates.io | dps422 |
lib.rs | dps422 |
version | 0.1.1 |
source | src |
created_at | 2020-05-11 11:54:07.664437 |
updated_at | 2020-05-11 12:31:41.823769 |
description | A platform agnostic driver to interface with the DPS422 barometric pressure & temp sensor through I2C |
homepage | |
repository | https://github.com/devboard-io/dps422-rs |
max_upload_size | |
id | 240093 |
size | 32,084 |
A platform agnostic driver to interface with the DPS422 barometric pressure & temp sensor. This driver uses I2C via embedded-hal. Note that the DPS422 also supports SPI, however that is not (yet) implemented in this driver.
Include this crate as a dependency in your Cargo.toml
[dependencies.dps422]
version = "<version>"
Use embedded-hal implementation to get I2C, then create a driver instance
use dps422::{DPS422, self};
let address = 0x76;
let mut dps = DPS422::new(i2c, address, &dps422::Config::new()).unwrap();
dps.trigger_measurement(true, true, false).unwrap();
if dps.data_ready().unwrap() {
let pressure = dps.read_pressure_calibrated().unwrap();
let temp = dps.read_temp_calibrated().unwrap();
writeln!(usart, "pressure: {:.1} [kPa]\t temp: {:.1} [˚C]", pressure, temp).unwrap();
}