DHT11 not reading with nodemcu. Help, I'm new!

Posted on
  • I am simply trying to get the DHT11 to display the temperature in the console of the web IDE through my nodemcu. I'm very new at this, but must be doing something wrong. I modified the code found here: http://www.espruino.com/DHT11 It is constantly returning -1 for both temperature and humidity. If I disconnect everything, it still shows "-1" ...so I'm apparently receiving no data?

    I've tried to get it working in two ways:

    Using "NodeMCU" in the code:

    var dht = require("DHT11").connect(NodeMCU.D1);
    dht.read(function (a) {console.log("Temp is "+a.temp.toString()+" and RH is "+a.rh.toString());});
    

    Declaring pins directly:

    var dht = require("DHT11").connect(D5);
    dht.read(function (a) {console.log("Temp is "+a.temp.toString()+" and RH is "+a.rh.toString());});
    

    Attached is a GPIO reference picture that matches my nodemcu.

    The DHT11 unit I'm using an Osepp DHT11 unit. More info: http://osepp.com/products/sensors-arduin­o-compatible/humidity-temperature-sensor­/

    What am I missing? Do I need some type of resistor in the mix? Have I connected it wrong? This is my first project, an any help you can give me would be greatly appreciated! Thanks!


    1 Attachment

    • nodemcudevkit_v1-0_io.jpg
  • Try putting a 1k pullup to Vcc on the data line.

    Also, DHT11's are terrible - the temperature is okay, the humidity is very often totally bogus. The DHT22 sucks less. Both of them will instantly fail if you connect power backwards, so don't do that.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

DHT11 not reading with nodemcu. Help, I'm new!

Posted by Avatar for greg @greg

Actions