pub struct Thermo<I2C> { /* private fields */ }Expand description
Driver for the Modulino Thermo module (HS3003 sensor).
This driver wraps the hs3003 crate
to provide temperature and humidity measurements.
§Example
ⓘ
use modulino::Thermo;
let mut thermo = Thermo::new(i2c);
// Read temperature and humidity (requires a delay provider)
let measurement = thermo.read(&mut delay)?;
println!("Temperature: {:.1}°C", measurement.temperature);
println!("Humidity: {:.1}%", measurement.humidity);Implementations§
Source§impl<I2C, E> Thermo<I2C>where
I2C: I2c<Error = E>,
impl<I2C, E> Thermo<I2C>where
I2C: I2c<Error = E>,
Sourcepub fn new(i2c: I2C) -> Self
pub fn new(i2c: I2C) -> Self
Create a new Thermo instance.
The HS3003 sensor has a fixed I2C address of 0x44.
Sourcepub fn temperature<D: DelayNs>(&mut self, delay: &mut D) -> Result<f32, E>
pub fn temperature<D: DelayNs>(&mut self, delay: &mut D) -> Result<f32, E>
Read temperature only.
Convenience method that reads a full measurement and returns only the temperature value.
Sourcepub fn humidity<D: DelayNs>(&mut self, delay: &mut D) -> Result<f32, E>
pub fn humidity<D: DelayNs>(&mut self, delay: &mut D) -> Result<f32, E>
Read humidity only.
Convenience method that reads a full measurement and returns only the humidity value.
Auto Trait Implementations§
impl<I2C> Freeze for Thermo<I2C>where
I2C: Freeze,
impl<I2C> RefUnwindSafe for Thermo<I2C>where
I2C: RefUnwindSafe,
impl<I2C> Send for Thermo<I2C>where
I2C: Send,
impl<I2C> Sync for Thermo<I2C>where
I2C: Sync,
impl<I2C> Unpin for Thermo<I2C>where
I2C: Unpin,
impl<I2C> UnwindSafe for Thermo<I2C>where
I2C: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more