I am developing for the NodeMCU V0.9 with the NonOS SDK and can't get it to communicate to a DHT22 sensor.

Wiring: 3.3V on NodeMCU -> + on DHT22, Ground to - and pin D1 to signal, there is a 6.8k pull up resistor on the data line.

According to the DHT22 datasheet, the MCU has to start by pulling the data line low for a bit more then 1 ms after having it on high for 1 ms and then hast to listen to what the DHT22 is sending.

My code for doing this is the following:

gpio_output_set(_pinNumber, 0, _pinNumber, 0);
gpio_output_set(0, _pinNumber, _pinNumber, 0);
gpio_output_set(0, 0, 0, _pinNumber);

I was able to verify that the NodeMCU behaves as expected by using a logic analyzer (see picture) pulse low for 1.1 ms

I ruled out a defective DHT22 by trying 3 different ones. The DHT22 doesn't answer with the data as expected.

Has anyone encountered this behavior?

  • \$\begingroup\$ No, because those aren't available for the NonOs SDK \$\endgroup\$
    – elhe
    Jul 3, 2019 at 20:11
  • \$\begingroup\$ I have my information from this library and copied how the code works. I also read through the adafruit tutorial. \$\endgroup\$
    – elhe
    Jul 3, 2019 at 20:15
  • \$\begingroup\$ The datasheet states that between 3.3V and 6V is ok. I am using 3.3V, but also tried the 5V output of the NodeMCU \$\endgroup\$
    – elhe
    Jul 3, 2019 at 20:28
  • \$\begingroup\$ @vicatcu Do you want to formulate your comment about using a library to check out what works, as a answer so I can accept it. I tried the adafruit library with an arduino and was able to find out, that my seller sold me a DHT11 instead of a DHT22 so my timing was off. Your comment led me to my answer. \$\endgroup\$
    – elhe
    Jul 6, 2019 at 14:02

1 Answer 1


Have you tried using one of the myriad Arduino libraries that talk to the DHT22? For example, read through learn.adafruit.com/dht? Their source code is open and you can emulate what they do in whatever manner you like.

I recommend you run the code from some library and observe it actually working, and then use your logic analyzer to see what that code is actually doing, rather than counting on your inspection / reading of the code. Chances are you missed some nuance of what the library you are using as a reference is doing.

  • \$\begingroup\$ Running a working library helped me find my problem, thanks. \$\endgroup\$
    – elhe
    Jul 8, 2019 at 8:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.