Expand description
§MS4525DO Airspeed Sensor Driver
A platform-agnostic Rust driver for the MS4525DO differential pressure sensor, commonly used for airspeed measurement in drones and aircraft.
§Features
- Dual API: Both blocking and async implementations
- Platform agnostic: Works on any platform with I2C support
no_stdcompatible: Suitable for embedded systems- Zero dynamic allocation: All operations use stack memory
- Validated readings: Double-read validation ensures data freshness
- Flexible logging: Optional
defmtorlogsupport
§Usage
§Blocking API
ⓘ
use ms4525do::blocking::Ms4525do;
use embedded_hal::delay::DelayNs;
let mut sensor = Ms4525do::new(i2c);
let mut delay = /* your delay implementation */;
match sensor.read_data(&mut delay) {
Ok((pressure_pa, temp_c)) => {
let airspeed = ms4525do::calculate_airspeed(pressure_pa, temp_c);
println!("Airspeed: {:.2} m/s", airspeed);
}
Err(e) => println!("Error: {:?}", e),
}§Async API
ⓘ
use ms4525do::async_api::Ms4525do;
use embassy_time::{Duration, Timer};
let mut sensor = Ms4525do::new(i2c);
match sensor.read_data().await {
Ok((pressure_pa, temp_c)) => {
let airspeed = ms4525do::calculate_airspeed(pressure_pa, temp_c);
println!("Airspeed: {:.2} m/s", airspeed);
}
Err(e) => println!("Error: {:?}", e),
}§Feature Flags
async(default): Enable async API with embassy-timeblocking: Enable blocking/synchronous APIstd: Enable std support (for desktop/server environments)defmt: Enable defmt logging for embedded debugginglog: Enable log facade for flexible logging
§Sensor Details
The MS4525DO is a digital differential pressure sensor with:
- I2C interface (default address: 0x28)
- 14-bit pressure resolution
- 11-bit temperature resolution
- ±1 PSI measurement range (001PD variant)
- Operating temperature: -50°C to +150°C
Modules§
- async_
api - Asynchronous (non-blocking) API for MS4525DO sensor communication.
- blocking
- Blocking (synchronous) API for MS4525DO sensor communication.
Enums§
- Ms4525do
Error - Errors that can occur during MS4525DO sensor operations.
- Status
- Status codes returned by the MS4525DO sensor.
Functions§
- calculate_
airspeed - Calculates airspeed from differential pressure and temperature.