A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/michaelbeaumont/dht-sensor below:

michaelbeaumont/dht-sensor: Rust embedded-hal based driver for the DHT11/DHT22 sensor

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.

The only prerequisites are an embedded-hal implementation that provides:

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.

See the following examples for how to use the library.

Release mode may be required

Compiling in debug mode may disturb the timing-sensitive parts of this crate and ultimately lead to failure. In this case, you will likely receive a Timeout error. Try compiling with --release instead.

To run the tests, use something like cargo test --lib --target x86_64-unknown-linux-gnu.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4