Skip to main content

Hs3003

Struct Hs3003 

Source
pub struct Hs3003<I2C> { /* private fields */ }
Expand description

HS3003 temperature and humidity sensor driver

Implementations§

Source§

impl<I2C, E> Hs3003<I2C>
where I2C: I2c<Error = E>,

Source

pub fn new(i2c: I2C) -> Self

Creates a new HS3003 driver instance with the default I2C address (0x44)

§Arguments
  • i2c - An I2C interface implementing the embedded_hal::i2c::I2c trait
§Example
let sensor = Hs3003::new(i2c);
Source

pub fn new_with_address(i2c: I2C, address: u8) -> Self

Creates a new HS3003 driver instance with a custom I2C address

§Arguments
  • i2c - An I2C interface implementing the embedded_hal::i2c::I2c trait
  • address - Custom I2C address for the sensor
§Example
let sensor = Hs3003::new_with_address(i2c, 0x44);
Source

pub fn read<D>(&mut self, delay: &mut D) -> Result<Measurement, Error<E>>
where D: DelayNs,

Triggers a measurement and reads temperature and humidity

This function:

  1. Sends a measurement request to the sensor
  2. Waits for the measurement to complete (100ms)
  3. Reads the raw data from the sensor
  4. Converts the raw data to temperature and humidity values
§Arguments
  • delay - A delay provider implementing embedded_hal::delay::DelayNs
§Returns

A Result containing a Measurement with temperature and humidity values, or an Error if the operation fails.

§Example
let mut sensor = Hs3003::new(i2c);
let measurement = sensor.read(&mut delay)?;
// Use measurement.temperature and measurement.humidity
Source

pub fn destroy(self) -> I2C

Destroys the driver and returns the I2C interface

This allows the I2C bus to be reused for other devices.

§Example
let sensor = Hs3003::new(i2c);
let mut i2c = sensor.destroy();

Trait Implementations§

Source§

impl<I2C: Debug> Debug for Hs3003<I2C>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<I2C> Freeze for Hs3003<I2C>
where I2C: Freeze,

§

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

§

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

§

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

§

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

§

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

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

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 T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.