First, thank for your work on this library. It's been working great for reading my DHT22.
Issue
The code as-is populates the DhtValue struct with the raw u8s from my sensor. Calling the temperature() or humidity() functions results in me being returned either a 0.0 or 1.0 regardless of the underlying raw data in the DhtValue.value array.
use dht_hal_drv;
use spin_sleep;
# Setup I2C pins
let dht_read = dht_hal_drv::dht_read(dht_hal_drv::DhtType::DHT22, &mut dht22pin, &mut |d| {
spin_sleep::sleep(time::Duration::from_micros(d as u64));
});
match dht_read {
Ok(reading) => {
println!("Reading: {:?}", &reading);
println!("Temp: {:.1}\t Hum: {:.1}", reading.temperature(), reading.humidity());
}
Err(e) => println!("Error: {:?}", e),
}
Looking in to this I noticed the crate compiles but does emit some warnings:
warning[E0170]: pattern binding `DHT11` is named the same as one of the variants of the type `DhtType`
--> dht-hal-drv/src/lib.rs:125:13
|
125 | DHT11 => self.value[2] as f32,
| ^^^^^ help: to match on the variant, qualify the path: `DhtType::DHT11`
|
= note: `#[warn(bindings_with_variant_name)]` on by default
Changing the values in the match statements in the temperature() and humidity() functions to the fully qualified enum variant addresses these and other warnings:
First, thank for your work on this library. It's been working great for reading my DHT22.
Issue
The code as-is populates the
DhtValue
struct with the rawu8
s from my sensor. Calling thetemperature()
orhumidity()
functions results in me being returned either a0.0
or1.0
regardless of the underlying raw data in theDhtValue.value
array.Returns:
Fix
Looking in to this I noticed the crate compiles but does emit some warnings:
Changing the values in the match statements in the
temperature()
andhumidity()
functions to the fully qualified enum variant addresses these and other warnings:With this in place the output is now as expected: