dht22-sensor

Crates.iodht22-sensor
lib.rsdht22-sensor
version0.1.0
created_at2025-07-23 01:57:59.858196+00
updated_at2025-07-23 01:57:59.858196+00
descriptionA no_std driver for the DHT22 (AM2302) temperature and humidity sensor
homepage
repositoryhttps://github.com/implferris/dht22-sensor
max_upload_size
id1764289
size24,563
impl Ferris (ImplFerris)

documentation

README

DHT22 Sensor Driver

A platform-agnostic driver for the DHT22 (AM2302) temperature and humidity sensor using [embedded-hal] traits.
Designed for use in no_std embedded environments.


Features

  • Supports blocking reads from the DHT22 sensor.
  • Compatible with any platform that implements [embedded-hal] traits.
  • no_std support.
  • Tested using embedded-hal-mock.

Usage

Add this to your Cargo.toml:

[dependencies]
# dht22-sensor = "0.1" 
dht22-sensor = { git = "https://github.com/implferris/dht22-sensor" }

Example

use dht22_sensor::Dht22;
use embedded_hal::digital::{InputPin, OutputPin};
use embedded_hal::delay::DelayNs;

// `pin` must support switching between input/output modes.
// `delay` should implement DelayNs for microsecond delays.

let mut dht = Dht22::new(pin, delay);
match dht.read() {
    Ok(reading) => {
        info!("Temperature: {:.1} °C", reading.temperature);
        info!("Humidity: {:.1} %", reading.humidity);
    }
    Err(e) => {
        error!("DHT22 read error: {:?}", e);
    }
}

License

MIT

Commit count: 0

cargo fmt