'Read DHT22 with Rust on HiFive1 rev b

Im trying to read my DHT22 weather and humidity sensor on HiFive1 rev b board, but it doesn't want to respond. I connected data line with 10k resistor to 5V Vcc on bred board (power to bred board is from 5V pin on board and GND is from GND from board too) from which im powering my sensor too. Here is my code based on example from here and C example from this site:

#![no_std]
#![no_main]

/*
* Basic blinking external LED using GPIO pin example.
* WARNING: requires a LED to be wired to physical PIN9 with at least
* a 320 Ohm resistor in series similar to
* https://create.arduino.cc/projecthub/rowan07/make-a-simple-led-circuit-ce8308
*/

extern crate panic_halt;

use hifive1::hal::delay::Sleep;
use hifive1::hal::prelude::*;
use hifive1::hal::DeviceResources;
use hifive1::{pin, sprintln};
use riscv_rt::entry;

#[entry]
fn main() -> ! {
    let dr = DeviceResources::take().unwrap();
    let p = dr.peripherals;
    let pins = dr.pins;

    // let pins = dr.pins;

    // Configure clocks
    let clocks = hifive1::clock::configure(p.PRCI, p.AONCLK, 320.mhz().into());

    let mut eled = pin!(pins, dig9).into_output();

    // GPIO PIN1 -> DIG9 physical on board (both hifive1 and hifive1-revB)
    



    hifive1::stdout::configure(
        p.UART0,
        pin!(pins, uart0_tx),
        pin!(pins, uart0_rx),
        115_200.bps(),
        clocks,
    );

    // get the local interrupts struct
    let clint = dr.core_peripherals.clint;

    // get the sleep struct
    let mut sleep = Sleep::new(clint.mtimecmp, clocks);

    const PERIOD: u32 = 1000; // 1s
    sprintln!("loop");
    loop {
        
        eled.set_low().unwrap();
        sleep.delay_ms(20);
        eled.set_high().unwrap();
        sleep.delay_ms(35);
        sprintln!("sent");
        
       
        let mut eled_input = eled.into_floating_input();

        sprintln!("recive");
        loop {
            let recive = eled_input.is_high().unwrap();
            sprintln!("{}", recive);
            sleep.delay_ms(30);
        }

        // // sleep for 1s
        eled = eled_input.into_output();
        sleep.delay_ms(PERIOD);
    }
}

Im getting on serial output only high state on pin nothing is changing. What am i doing wrong?

EDIT:

I buy another sensor and its not working too. I reviewed additional libraries like here and it looks for other processor sensor is initialized same way.

I checked pin too and connecting it to ground showing low state so board is working so im making probably some error in code.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source