Jump to content

Recommended Posts

Posted

I'm trying to use the kernel-driver (1) for a DHT11 (or DHT22) humidity sensor with my NanoPi NEO.

 

I'm already got this sensors working with some little C example-programs in userspace.

 

I figured out that I need to apply a Device Tree overlay because the driver (dht11.c) needs to know the gpio-pin where the sensor is connected to.

 

So - I don't know how to write such a file from scratch - I customised a existing overlay file - "sun8i-h3-pps-gpio.dts" (2) - only the lines "pins" (PG6) & "compatible with" (dht11) & "gpios" (&pio 6 6 1)

 

/dts-v1/;
/plugin/;

/ {
    compatible = "allwinner,sun8i-h3";

    fragment@0 {
        target = <&pio>;
        __overlay__ {
            pps_pins: pps_pins {
                pins = "PG6";
                function = "gpio_in";
            };
        };
    };

    fragment@1 {
        target-path = "/";
        __overlay__ {
            pps@0 {
                compatible = "dht11";
                pinctrl-names = "default";
                pinctrl-0 = <&pps_pins>;
                gpios = <&pio 6 6 1>; /* PG6 */
                status = "okay";
            };
        };
    };
};

 

With this overlay file applied ("armbian-add-overlay ...") the driver module is loading on boot and the directories and files in the iio-subsystem are created (eg. /sys/bus/iio/devices/iio\:device0/in_humidityrelative_input)

 

When I try to read from the sensor I got the following error in my terminal

cat: '/sys/bus/iio/devices/iio:device0/in_humidityrelative_input': Connection timed out

and this on the serial console

dht11 pps@0: Only 25 signal edges detected

 

According to the source of the driver there should be 84 edges to detect - something seems to be to slow ...

 

When it is possible to read from the sensor with userspace programs so it should be also possible to do the same thing with a kernel driver - right?

 

So I'm thinking, that the error should be in my overlay file ... but I am at my wit's end.

 

Maybe somebody can help me?

 

(1) https://github.com/torvalds/linux/blob/master/drivers/iio/humidity/dht11.c

(2) https://github.com/armbian/sunxi-DT-overlays/blob/master/sun8i-h3/sun8i-h3-pps-gpio.dts

 

(my English lessons in school are 15 years ago, so please excuse)

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines