DHT11 character device register - wait state
-
Hi,
I have been trying to setup DHT11 sensor to read the temperature and humidity values using Spresense SDK.I have been facing an issue of forever waiting state when I am trying to open my registered DHT11 sensor character device in the NuttX Operating System in Spresense Main and Extension board.
Setup: The signal pin of the DHT11 is connected to D06 or PIN_PWM0 in the extension board. The Vcc of sensor is connected to 3.3V and ground pin is wired to ground in the extension board. For the device driver, I am using the prebuilt Dhtxx driver (https://github.com/sonydevworld/spresense-nuttx/blob/new-master/drivers/sensors/dhtxx.c).
My setup is working well when trying to read using the Arduino IDE with Spresense.
Program:
The goal of the program was to register a character device of PIN_PWM0 or Digital pin 6 and reading data from the DHT11 sensor. I have enabled the driver support for Dhtxx in the SDK configuration, so as to register the device for reading the sensor values. The Dhtxx driver requires configuration functions- config_data_pin
- set_data_pin
- read_data_pin
- get_clock
For registering the Dhtxx character device driver.
The below image shows my configuration of each function for configuring and linking digital pin6 or PIN_PWM0 using GPIO.
For registering the device, I have used dhtxx_register with the above configuration. Then the device has been open in read only mode for reading the data. Once the device is open, it has to be read using the read function (similar to Dhtxx example). Executing the program leads to the issue.
Issue: when the open function is called, the program freezes or goes into infinite waiting state unable to move forward in the program. The program freezes after displaying Initialised and is unable to display "Device in read mode", acknowledging that device is opened. It is unable to move forward to read the data from the sensor.
The below image showcases the wait state of the program.
Any support will be immensely helpful.
Thanks in advance. -
Could you add extra printf to the dhtxx_open() function: https://github.com/sonydevworld/spresense-nuttx/blob/64d9f015412d72da9dd85f478dd7039377391c3a/drivers/sensors/dhtxx.c#L412
I'd like you to locate where this function gets stuck and check if it is called.
Best Regards,
Kamil Tomaszewski -
Hi @kamiltomaszewski ,
I have put the printf functions in Dhtxx driver file and it is getting stuck at nxsem_wait_uninterruptible function.
-
@shibi-s-kumar Could you please try to add here: https://github.com/sonydevworld/spresense-nuttx/blob/64d9f015412d72da9dd85f478dd7039377391c3a/drivers/sensors/dhtxx.c#L600
this line:nxsem_init(&priv->devsem, 0, 1);
-
Hi @kamiltomaszewski ,
Thanks a lot.
nxsem_init(&priv->devsem, 0, 1);
Worked and I was able to get through the semaphore.
Although I am getting a TIMEOUT error when trying read the sensor data due to misconfigured clock. I'll try to reconfigure the get_clock function.