Crate ms5611_i2c

Source
Expand description

MS5611 pressure sensor driver using I2C.

This library supports both synchronous and asynchronous modes of operation. The mode is selected using the sync and async features. Only one of these features can be enabled at a time.

§Features

  • sync: Enables synchronous mode using embedded_hal traits.
  • async: Enables asynchronous mode using embedded_hal_async traits.

§Example

use ms5611_i2c::{Ms5611, OversamplingRatio};
use embedded_hal::blocking::i2c::{Write, WriteRead};

// Create an instance of the I2C bus (implementation specific)
let i2c = ...;

// Create an instance of the MS5611 sensor
let mut sensor = Ms5611::new(i2c, None).unwrap();

// Reset the sensor
sensor.reset().unwrap();

// Read a sample with a specific oversampling ratio
let sample = sensor.read_sample(OversamplingRatio::Opt4096).unwrap();

println!("Pressure: {} mbar, Temperature: {} °C", sample.pressure_mbar, sample.temperature_c);

§Errors

The library defines a custom error type MS5611Error which can represent the following errors:

  • I2CError: An error occurred during I2C communication.
  • BadChecksum: The checksum of the PROM data did not match.
  • BadProm: The PROM data is invalid.
  • NoProm: The PROM data could not be read.
  • BadAddress: The I2C address is invalid.
  • BadOsr: The oversampling ratio is invalid.

§Structs

  • Ms5611: Represents the MS5611 pressure sensor.
  • Ms5611Sample: Represents a sample of pressure and temperature data.
  • Prom: Represents the factory calibrated data stored in the sensor’s ROM.

§Enums

  • MS5611Error: Represents the possible errors that can occur.
  • OversamplingRatio: Represents the available oversampling ratios.

§Methods

  • Ms5611::new: Creates a new instance of the MS5611 sensor.
  • Ms5611::reset: Resets the sensor.
  • Ms5611::read_sample: Reads a sample of pressure and temperature data.
  • OversamplingRatio::get_delay: Returns the delay required for the given oversampling ratio.
  • OversamplingRatio::addr_modifier: Returns the address modifier for the given oversampling ratio.

Structs§

Ms5611
Pressure sensor
Ms5611Sample
Output from the MS5611.

Enums§

MS5611Error
OversamplingRatio
Oversampling ratio See datasheet for more information.