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>
impl<PIN, DELAY, E> Dht22<PIN, DELAY>
Sourcepub fn new(pin: PIN, delay: DELAY) -> Self
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 theDelayNstrait.
Sourcepub fn read(&mut self) -> Result<Reading, DhtError<E>>
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>
impl<PIN, D> RefUnwindSafe for Dht22<PIN, D>where
PIN: RefUnwindSafe,
D: RefUnwindSafe,
impl<PIN, D> Send for Dht22<PIN, D>
impl<PIN, D> Sync for Dht22<PIN, D>
impl<PIN, D> Unpin for Dht22<PIN, D>
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> 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