I've been trying to use a DHT11 temperature sensor with rppal. My code is the following:
rust
fn main() {
let mut pin = Gpio::new().unwrap().get(18).unwrap().into_io(Mode::Output);
let mut led = Gpio::new().unwrap().get(17).unwrap().into_output();
let mut sensor = Dht11::new(pin);
for _ in 0..10 {
led.set_high();
let measurement = sensor.perform_measurement(&mut Delay::new());
println!("{:?}", measurement);
led.set_low();
sleep(Duration::from_secs(1));
}
}
but measurement keeps being set to
Err(Timeout). I have tried using different IO modes and using different libraries too. This crate is
dht11, but I have also tried
dht-sensor and
simple-dht11, to no avail. I also haven't managed to get a measurement with a different language, Python kept crashing in the venv because it couldn't detect the environment.
I connected the VCC to the 3.3V supply, the ground to GND and the data line to GPIO 18. I'm pretty confident it's correctly connected cause I have an LED on my DHT11 that lights up, but I cannot make any measurements whatsoever.