Dht22

Struct Dht22 

Source
pub struct Dht22<Pin, Timer>
where Pin: IOPin, Timer: MicroTimer,
{ /* private fields */ }
Expand description

Represents a DHT22 sensor connected to a pin.

Implementations§

Source§

impl<Pin, Timer> Dht22<Pin, Timer>
where Pin: IOPin, <Pin as IOPin>::DeviceError: Debug, Timer: MicroTimer,

Source

pub fn new(pin: Pin, clock: Timer) -> Self

Construct a new representation of the DHT22 sensor. Construction is cheap as long as the pin and clock are cheap to move.

Source

pub fn read(&mut self) -> Result<SensorReading, DhtError<Pin::DeviceError>>

Attempt one read from the DHT22 sensor. Between subsequent reads from the same sensor at least 2 seconds should pass to avoid erratic readings. Reading to early after startup may also result in failure to read.

Auto Trait Implementations§

§

impl<Pin, Timer> Freeze for Dht22<Pin, Timer>
where Pin: Freeze, Timer: Freeze,

§

impl<Pin, Timer> RefUnwindSafe for Dht22<Pin, Timer>
where Pin: RefUnwindSafe, Timer: RefUnwindSafe,

§

impl<Pin, Timer> Send for Dht22<Pin, Timer>
where Pin: Send, Timer: Send,

§

impl<Pin, Timer> Sync for Dht22<Pin, Timer>
where Pin: Sync, Timer: Sync,

§

impl<Pin, Timer> Unpin for Dht22<Pin, Timer>
where Pin: Unpin, Timer: Unpin,

§

impl<Pin, Timer> UnwindSafe for Dht22<Pin, Timer>
where Pin: UnwindSafe, Timer: 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.