https://github.com/implferris/dht22-sensor
https://github.com/implferris/dht22-sensor
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/implferris/dht22-sensor
- Owner: ImplFerris
- License: mit
- Created: 2025-07-23T01:57:09.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2025-07-23T01:57:12.000Z (6 months ago)
- Last Synced: 2025-07-23T02:02:11.161Z (6 months ago)
- Language: Rust
- Size: 0 Bytes
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-MIT
Awesome Lists containing this project
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`:
```toml
[dependencies]
# dht22-sensor = "0.1"
dht22-sensor = { git = "https://github.com/implferris/dht22-sensor" }
```
### Example
```rust
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