Page 1 of 1

dht11 example

Posted: 2024-01-08 19:58
by kkuras
Hi,
I've got Lucfox Pico Pro/Max, as first job I would like to run DHT22 sensor, it is compatible with DHT11 by the way.
Of course I read Your tutorial from here:
https://wiki.luckfox.com/Luckfox-Pico/L ... Pico-dht11

But, reading sdk I've noticed that probably instruction from link above is depracated right becouse there is already built in driver for DHT sensor in sdk. I mean:
/sysdrv/source/kernel/drivers/iio/humidity/dht11.c

I enabled this driver using menuconfig and instruction from link below:
https://wiki.luckfox.com/Luckfox-Pico/L ... Menuconfig

Then, according to devicetree documentation from location
/sysdrv/source/kernel/Documentation/devicetree/bindings/iio/humidity/dht11.txt
I modified device tree for my board
/sysdrv/source/kernel/arch/arm/boot/dts/rv1106g-luckfox-pico-pro-max.dts
by adding definition acording to documentation, top of my device tree looks like below
// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
/*
* Copyright (c) 2022 Rockchip Electronics Co., Ltd.
*/

/dts-v1/;

#include "rv1106.dtsi"
#include "rv1106-evb.dtsi"
#include "rv1106-luckfox-pico-pro-max-ipc.dtsi"

/ {
model = "Luckfox Pico Max";
compatible = "rockchip,rv1103g-38x38-ipc-v10", "rockchip,rv1106";

dht22 {
status = "okay";
compatible = "dht11";
gpios = <&gpio1 7 0>;
};
};

I commented PWM11 periphery as well.
//&pwm11 {
// status = "okay";
// pinctrl-names = "active";
// pinctrl-0 = <&pwm11m1_pins>;
// // pinctrl-0 = <&pwm11m2_pins>;
// // pinctrl-0 = <&pwm11m0_pins>;
//};

After pristin build and flashing I can't see /dev/dht22 device... Am I doing wrong something?

Re: dht11 example

Posted: 2024-01-09 12:55
by Luckfox Taylor
Hello,

In general, you would need to research this information on your own. You can write the device tree according to the format in our Wiki. Rockchip has its own device tree writing standards. There are clear syntax errors in your device tree. In the gpios property, the correct syntax should be:

Code: Select all

gpios = <&gpio1 RK_PC7 GPIO_ACTIVE_LOW>;

Re: dht11 example

Posted: 2024-01-10 20:56
by kkuras
Thanks for Your answer.

Of course device tree error with gpios is already fixed and still there is the same result after flashing board - there is no /dev/dht22 device.
What I need is answer to questions:
DHT11 run instruction on Your wiki is deprecated? [Yes/No]
Aproach to run DHT11 that I described above is correct? [Yes/No]

What You mean "Rockchip has its own device tree writing standards.", it was only about RK_PC7 gpios property, or all of my configuration is wrong? [...]

Maybe I should told that I'm new in Linux drivers programming/modyfication.

Best regards,
Kamil

Re: dht11 example

Posted: 2024-01-11 2:50
by Eng38
Dear Kamil,

Thanks for your follow-up question. The answer is as follows:
  • Regarding the DHT11 run instructions on our wiki, the answer is no, it is not deprecated and is still valid.
  • Regarding the method of running DHT11 you described above, there seems to be some configuration missing from your setup.
I noticed that you have managed to rectify an issue within the device tree. Nevertheless, to fully utilize the DHT11 sensor, kernel-level support is imperative. Our wiki illustrates how this support can be attained by dynamically importing a kernel module (.ko file). Additionally, you have the option to activate DHT11 support by properly configuring the kernel during its build process using the menuconfig tool at the following link: https://wiki.luckfox.com/Luckfox-Pico/L ... enuconfig/

Temperature data can be obtained via the following path: /sys/bus/iio/devices/iio:device1/in_temp_input
Humidity data can be read from the following path: /sys/bus/iio/devices/iio:device1/in_humidityrelative_input

Once the kernel is properly configured and supports the DHT11 sensor, these IIO interfaces will provide real-time temperature and humidity measurements.

Re: dht11 example

Posted: 2024-01-11 19:46
by kkuras
Thank You for Your detailed answer.

Within my description I mentioned that I enabled dht11 driver using menuconfig :)

I would like to ask about:
Temperature data can be obtained via the following path: /sys/bus/iio/devices/iio:device1/in_temp_input
Humidity data can be read from the following path: /sys/bus/iio/devices/iio:device1/in_humidityrelative_input
It means that I shouldn't expect /dev/dht22 device to be present in devices list?

Best regards,
Kamil

Re: dht11 example

Posted: 2024-01-12 2:18
by Eng38
Dear Kamil,

I noticed that you've enabled the dht11 driver using menuconfig.Indeed, in this case, the /dev/dht22 device node is not created via a traditional character device interface; rather, it is accessed through the sysfs interface provided by the IIO (Industrial Input/Output) framework. Therefore, it's entirely normal not to find /dev/dht22 within the /dev directory path.