Struct ms8607::MS8607

source ·
pub struct MS8607<I2C> { /* private fields */ }
Expand description

A platform agnostic Rust driver for the MS8607 Pressure, Temperature, and Humidity Sensor from TE Connectivity.

Example

// Create a new instance of the MS8607 driver
let mut ms8607 = MS8607::new(i2c);
// Initialize and calibrate the sensor
let begin = ms8607.begin(&mut delay);
// Init OK, sensor foun

// Get measurements
let (pres, temp, hum) = ms8607.get_measurements(&mut delay).unwrap();
hprintln!("Pressure: {pres:.2} Pa, Temperature: {temp:.2} C, Humidity: {hum:.2} %RH\r");

Implementations§

source§

impl<I2C, E> MS8607<I2C>where
I2C: Write<Error = E> + WriteRead<Error = E>,

source

pub fn new(i2c: I2C) -> Self

Create a new MS8607 instance

source

pub fn begin<Delay>(&mut self, delay: &mut Delay) -> Result<(), Error<E>>where
Delay: DelayMs<u16>,

Sets up the hardware and initializes I2C

source

pub fn init(&mut self) -> Result<(), Error<E>>

Initializer for post i2c/spi init

source

pub fn enable_humidity_clock_stretching(&mut self, enable_stretching: bool)

Allow the MS8607 to hold the clock line low until it completes the requested measurements

Arguments

enable_stretching: true to enable clock stretching, false to disable

source

pub fn set_humidity_resolution(
&mut self,
resolution: Ms8607HumidityResolution
) -> Result<(), Error<E>>

Set the resolution for humidity readings

Arguments

resolution: the resolution to set

source

pub fn set_pressure_resolution(&mut self, resolution: Ms8607PressureResolution)

Set the resolution for pressure readings

Arguments

resolution: the resolution to set

source

pub fn get_humidity_resolution(
&mut self
) -> Result<Ms8607HumidityResolution, Error<E>>

Get the currently set resolution for humidity readings

source

pub fn get_pressure_resolution(&self) -> Ms8607PressureResolution

Get the currently set resolution for pressure readings

source

pub fn get_measurements<Delay>(
&mut self,
delay: &mut Delay
) -> Result<(f64, f64, f64), Error<E>>where
Delay: DelayMs<u16>,

source

pub fn reset<Delay>(&mut self, delay: &mut Delay) -> Result<(), Error<E>>where
Delay: DelayMs<u16>,

Reset the sensors to their initial state

Auto Trait Implementations§

§

impl<I2C> RefUnwindSafe for MS8607<I2C>where
I2C: RefUnwindSafe,

§

impl<I2C> Send for MS8607<I2C>where
I2C: Send,

§

impl<I2C> Sync for MS8607<I2C>where
I2C: Sync,

§

impl<I2C> Unpin for MS8607<I2C>where
I2C: Unpin,

§

impl<I2C> UnwindSafe for MS8607<I2C>where
I2C: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere
T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere
T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere
T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere
U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere
U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere
U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.