Sony's Developer World forum

    • Home
    • Forum guidelines

    DHT11 character device register - wait state

    Spresense
    2
    5
    656
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      sk_shibi last edited by

      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.

      Screenshot 2021-11-23 at 9.58.38 AM.png

      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.

      Screenshot 2021-11-23 at 10.07.46 AM.png

      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.
      image.png
      Any support will be immensely helpful.
      Thanks in advance.

      K 1 Reply Last reply Reply Quote
      • K
        KamilTomaszewski DeveloperWorld @sk_shibi last edited by

        Hi @shibi-s-kumar

        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

        S 1 Reply Last reply Reply Quote
        • S
          sk_shibi @KamilTomaszewski last edited by

          Hi @kamiltomaszewski ,

          I have put the printf functions in Dhtxx driver file and it is getting stuck at nxsem_wait_uninterruptible function.

          Screenshot 2021-11-23 at 6.10.19 PM.png

          K 1 Reply Last reply Reply Quote
          • K
            KamilTomaszewski DeveloperWorld @sk_shibi last edited by

            @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);
            
            S 1 Reply Last reply Reply Quote
            • S
              sk_shibi @KamilTomaszewski last edited by

              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.

              1 Reply Last reply Reply Quote
              • First post
                Last post
              Developer World
              Copyright © 2021 Sony Group Corporation. All rights reserved.
              • Contact us
              • Legal