6 releases
new 0.3.3 | Jan 17, 2025 |
---|---|
0.3.2 | Jan 17, 2025 |
0.2.2 | Jan 17, 2025 |
0.1.0 | Jan 16, 2025 |
#310 in Embedded development
14KB
207 lines
embedded-hal
async and sync driver for the MS5803-14BA pressure sensor
This library provides a driver for the MS5803-14BA pressure sensor using the embedded-hal
async abstractions over I2C and Delay.
Usage
use ms5803_14ba::{PressureSensorDriver, DEFAULT_SENSOR_ADDRESS};
// Get an Device Specific I2c instance (Here: esp-rs)
let i2c = I2c::new(
peripherals.I2C0,
i2c::master::Config {
frequency: 40.kHz(),
timeout: None,
},
)
.with_sda(peripherals.GPIO6)
.with_scl(peripherals.GPIO1)
.into_async();
// Setup the driver
let mut sensor = PressureSensorDriver::new(i2c, embassy_time::Delay, DEFAULT_SENSOR_ADDRESS);
// Reset and init sensor
sensor.init().await.unwrap();
loop {
// Real value
let measurement = sensor.read().await.unwrap();
let result = format!(
"Sensor t = {:.2}°C p = {:.4}bar",
measurement.celsius(),
measurement.bar(),
);
info!("{=str}", &result);
Timer::after(Duration::from_secs(1)).await;
}
which logs:
INFO Sensor t = 19.46°C p = 1.0187bar
INFO Sensor t = 19.46°C p = 1.0190bar
...
more examples can be found here
The examples use an esp32c3 with embassy. You can use any other embedded-hal
impl though.
Pins are connected like this:
esp32-c3 pin | ms5803 sensor |
---|---|
GPIO6 | SDA |
GPIO1 | SCL |
3V3 | 3V3 |
GND | GND |
Dependencies
~205–720KB
~17K SLoC