Struct Dht

Source
pub struct Dht { /* private fields */ }
Expand description

Handle on a Dht device, can be used to read sensor data. The internal memmap reference is automatically cleared on drop.

Implementations§

Source§

impl Dht

Source

pub fn new(typ: DhtType, gpio_pin: usize) -> Result<Dht, GpioOpenError>

Create a new Dht struct, which can be used to read sensor data. Note: Specifying the wrong DhtType only results in absurd readings, but does not have any other risks. The gpio_pin is the GPIO number, not the pin number. You can find annotated visual charts for your PI’s layout online. Make sure you have specified the correct pin number. Pin numbers from 0..57 are allowed here, but only pins 0..39 are actually available on current PI hardware.

Source

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

Try to get a reading from the DHT sensor.
Note that reading from DHT sensors is inherently unreliable: expect one in three reads to fail, round about. Additionally, in rare cases individual reads may result in incorrect values. This is a hardware issue. If you need more reliable reads, read twice and make sure the results don’t deviate much.
Lastly, if you need accurate readings, cross-check your readings to some sensor you know to be correct, it has been reported online that some DHT modules report values that are offset from the actual value by some amount.

Auto Trait Implementations§

§

impl Freeze for Dht

§

impl RefUnwindSafe for Dht

§

impl !Send for Dht

§

impl !Sync for Dht

§

impl Unpin for Dht

§

impl UnwindSafe for Dht

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.