| Crates.io | dht22-sensor |
| lib.rs | dht22-sensor |
| version | 0.1.0 |
| created_at | 2025-07-23 01:57:59.858196+00 |
| updated_at | 2025-07-23 01:57:59.858196+00 |
| description | A no_std driver for the DHT22 (AM2302) temperature and humidity sensor |
| homepage | |
| repository | https://github.com/implferris/dht22-sensor |
| max_upload_size | |
| id | 1764289 |
| size | 24,563 |
A platform-agnostic driver for the DHT22 (AM2302) temperature and humidity sensor using [embedded-hal] traits.
Designed for use in no_std embedded environments.
embedded-hal] traits.no_std support.embedded-hal-mock.Add this to your Cargo.toml:
[dependencies]
# dht22-sensor = "0.1"
dht22-sensor = { git = "https://github.com/implferris/dht22-sensor" }
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);
}
}
MIT