0

There is no compiler error but output is showing timeout error. as per as the instruction given in https://github.com/RobTillaart/Arduino/issues/61

it says to increase the timeout factor but i did not found the constraints which were asked to be changed.here is the snapshot of serial monitor

  • 1
    I think you need to change the library files themselves. – Gerben Oct 8 '18 at 9:02
  • He has five dht libraries. Do you know which one you are using? The problem might be the nodemcu in combination with the library and the sensor. The dht11 and dht22 might behave differently than a few years ago. Some libraries cause a shortcut in the data signal, which is a serious problem for the nodemcu. The 'DHTLIB_TIMEOUT' is declared in the .h file. To be compatible with all arduino board, a timeout should be in milliseconds. – Jot Oct 8 '18 at 9:28
  • I didn't find any constraint named DHTLIB_TIMEOUT which should be there in .h file. I am using a NodeMCU board and i have tried three different DHT11 libraries but none of them seems to work. can you provide me the links from where can i download the necessary library – Kaiser Oct 8 '18 at 13:07
  • I don't know, there are so much more than 3 libraries. The libraries for the dht11 for a esp8266 is a big mess. Even the nodemcu code has troubles with the (newer) dht11 sensors: github.com/nodemcu/nodemcu-firmware/issues/2253 Which libraries did you try? Do you use a pullup resistor? What is the value of that resistor? Do you use long wires? Do you have another dht11 sensor, perhaps this one is broken. If you want to know the humidity then perhaps you should buy a better sensor with i2c. The dht11 returns a number that has little to do with the humidity, it is not accurate. – Jot Oct 8 '18 at 14:06
  • The dht11 that i was using had an onboard pull up register and i didn't use any sort of wire just jumper cables for minimalist connection.and i have tried 2 different sensor but all produced NAN value I think instead of taking all this burden i will go for an i2c sensor. Thanks a lot @Jot – Kaiser Oct 9 '18 at 6:04
0

The DHT11 and DHT22 used to be cheap and easy to use humidity and temperature sensors when they were used together with an Arduino Uno.

But things have changed.

  • They are not accurate and can become totally inaccurate with certain gasses or fumes.
  • It turned out, that the most used DHT libraries have a serious bug that creates a shortcut in the datasignal. This was no problem with the Arduino Uno, which can output 40 mA with a pin. The newer processors have problems with that shortcut.
  • In 2018 the DHT11 seems to behave differently, the internal controller has probably changed.
  • Because the communication with the sensors requires accurate timing, the interrupts are turned off temporarily. That was no problem with the slow Arduino Uno, but it is not normal with a faster processor.
  • Some libraries use a timeout with a loop or with clock cycles. That worked well with the Arduino Uno, but it is not always reliable with newer processors.

In 2018, all the DHT libraries for the ESP8266 and ESP32 have issues with the DHT11 and DHT22.

Since the sensors are not very accurate anyway, it is best to stay away from all the troubles and avoid them. There are a number of good humidity sensors with I2C interface.

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.