Skip to main content

Dht22

Struct Dht22 

Source
pub struct Dht22<PIN, D> { /* private fields */ }
Expand description

Driver for the DHT22 temperature and humidity sensor.

Implementations§

Source§

impl<PIN, DELAY, E> Dht22<PIN, DELAY>
where PIN: InputPin<Error = E> + OutputPin<Error = E>, DELAY: DelayNs,

Source

pub fn new(pin: PIN, delay: DELAY) -> Self

Creates a new instance of the DHT22 driver.

§Arguments
  • pin - The GPIO pin connected to the DHT22 data line. Must support both input and output.
  • delay - A delay provider implementing the DelayNs trait.
Source

pub fn read(&mut self) -> Result<Reading, DhtError<E>>

Reads a temperature and humidity measurement from the DHT22 sensor.

This method performs the complete DHT22 communication sequence: sending a start signal, waiting for the sensor’s response, reading 5 bytes, validating the checksum, and decoding the result.

§Returns
  • Ok(Reading) if the read is successful and the checksum is valid.
  • Err(DhtError) if a communication or checksum error occurs.

Auto Trait Implementations§

§

impl<PIN, D> Freeze for Dht22<PIN, D>
where PIN: Freeze, D: Freeze,

§

impl<PIN, D> RefUnwindSafe for Dht22<PIN, D>

§

impl<PIN, D> Send for Dht22<PIN, D>
where PIN: Send, D: Send,

§

impl<PIN, D> Sync for Dht22<PIN, D>
where PIN: Sync, D: Sync,

§

impl<PIN, D> Unpin for Dht22<PIN, D>
where PIN: Unpin, D: Unpin,

§

impl<PIN, D> UnsafeUnpin for Dht22<PIN, D>
where PIN: UnsafeUnpin, D: UnsafeUnpin,

§

impl<PIN, D> UnwindSafe for Dht22<PIN, D>
where PIN: UnwindSafe, D: 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 = !

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.