Embassy DHT Sensor Library
This Rust library provides an interface for interacting with DHT1X and DHT2X temperature and humidity sensors using the Embassy framework.
test on raspberry pico (w) (RP2040) && Pico 2 (RP2350)
Getting Started
Installation
Add embassy-dht-sensor to your Cargo.toml:
[]
= "0.1.9"
Usage
Initialize your Raspberry Pi Pico board with Embassy. Create an instance of DHTSensor with the GPIO pin connected to your DHT sensor. Use the read method to get temperature and humidity readings.
Example for RP2040
// for dht22
use Spawner;
use *;
use ;
use embassy_rp;
use DHT22;
async
// for dht11
use Spawner;
use *;
use ;
use embassy_rp;
use DHT11;
async
New feature embedded_alloc
to enable it by ,add to Cargo.toml
= { = "0.1.9", = ["embedded_alloc"] }
when enable embedded_alloc we will get new fn in DHT11/DHT22 mod
Example for RP2350
for rp2350 need to use the crate embassy-rp from github.com
use rev="ee669ee5c57851ade034beca7cfaf81825c4c21b"
Cargo.toml
= { = "0.6.0", ="https://github.com/embassy-rs/embassy", ="ee669ee5c57851ade034beca7cfaf81825c4c21b", = ["task-arena-size-98304", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] }
= { = "0.3.2", ="https://github.com/embassy-rs/embassy", ="ee669ee5c57851ade034beca7cfaf81825c4c21b", = ["defmt", "defmt-timestamp-uptime"] }
= { = "0.1", ="https://github.com/embassy-rs/embassy", ="ee669ee5c57851ade034beca7cfaf81825c4c21b"}
= { = "0.2.0", ="https://github.com/embassy-rs/embassy", ="ee669ee5c57851ade034beca7cfaf81825c4c21b", = ["defmt", "unstable-pac", "time-driver", "critical-section-impl","rp235xa", "binary-info"] }
= { = "0.1.9", = [ "embedded_alloc"] }
...what crate you need
src/main.rs
use info;
use Spawner;
use ImageDef;
use ;
use i2c;
use ;
use ;
use DHT22;
pub static IMAGE_DEF: ImageDef = secure_exe;
async
examples
https://github.com/sndnvaps/embassy-dht/tree/main/examples/picow-display-embedded-alloc
https://github.com/sndnvaps/embassy-dht/tree/main/examples/picow-display
https://github.com/sndnvaps/embassy-dht/tree/main/examples/pico2-display
Pick up idea from https://crates.io/crates/embassy-dht-sensor