dps310

Crates.iodps310
lib.rsdps310
version0.1.5
sourcesrc
created_at2020-12-25 20:44:51.805545
updated_at2023-04-22 21:19:20.114173
descriptionA platform agnostic driver to interface with the DPS310 barometric pressure & temp sensor through I2C
homepage
repositoryhttps://github.com/dprotsiv/dps310-rs
max_upload_size
id327273
size41,673
(dprotsiv)

documentation

https://docs.rs/dps310

README

DPS310 - embedded-hal I2C driver crate

A platform agnostic driver to interface with the DPS310 barometric pressure & temp sensor. This driver uses I2C via embedded-hal. Note that the DPS310 also supports SPI, however that is not (yet) implemented in this driver.

Usage

Include this crate as a dependency in your Cargo.toml

[dependencies.dps310]
version = "<version>"

Use embedded-hal implementation to get I2C, then create a driver instance

use dps310::{DPS310, self};


let address = 0x77;
let mut dps = DPS310::new(i2c, address, &dps310::Config::new()).unwrap();

while !dps.init_complete().unwrap() || !dps.coef_ready().unwrap() {
    delay.delay_ms(200_u8);
}

dps.read_calibration_coefficients().unwrap();

dps.trigger_measurement(true, true, true).unwrap();

loop {
    delay.delay_ms(200_u8);
    if dps.temp_ready().unwrap() {
        let temp = dps.read_temp_calibrated().unwrap();
        iprintln!(stim, "Temperature: {:.1} [C]", temp);
    }
    
    if dps.pres_ready().unwrap() {
        let pressure = dps.read_pressure_calibrated().unwrap();
        iprintln!(stim, "Pressure: {:.1} [Pa]", pressure);
    }
}
Commit count: 14

cargo fmt