Expand description
§DHT11/DHT22 sensor driver
This library provides a platform-agnostic driver for the DHT11 and DHT22 sensors.
Use one of two functions dht11::blocking::read and dht22::blocking::read to get a reading.
§Usage
The only prerequisites are an embedded-hal implementation that provides:
DelayNs-implementing type, for example Cortex-M microcontrollers typically use theSysTick.InputPinandOutputPin-implementing type, for example anOutput<OpenDrain>fromstm32f0xx_hal.
When initializing the pin as an output, the state of the pin might depend on the specific chip
used. Some might pull the pin low by default causing the sensor to be confused when we actually
read it for the first time. The same thing happens when the sensor is polled too quickly in succession.
In both of those cases you will get a DhtError::Timeout.
To avoid this, you can pull the pin high when initializing it and polling the sensor with an interval of at least 500ms (determined experimentally). Some sources state a refresh rate of 1 or even 2 seconds.
§Example
See the following examples for how to use the library.