| Crates.io | ms5803-14ba |
| lib.rs | ms5803-14ba |
| version | 0.3.3 |
| created_at | 2025-01-16 23:52:27.392049+00 |
| updated_at | 2025-01-17 19:28:40.268123+00 |
| description | embedded-hal async and async driver for the MS5803-14BA pressure sensor |
| homepage | https://github.com/csicar/ms5803-14ba |
| repository | https://github.com/csicar/ms5803-14ba |
| max_upload_size | |
| id | 1520104 |
| size | 25,425 |
embedded-hal async and sync driver for the MS5803-14BA pressure sensorThis library provides a driver for the MS5803-14BA pressure sensor using the embedded-hal async abstractions over I2C and Delay.
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