DHT11 can't read

Posted on
  • Trying to read humidity and temp in a jar. Worked 20 minutes ago, but now all I get is:

    { "err": true, "checksumError": false,
      "raw": "",
      "temp": -1, "rh": -1 }
    Temp is -1 and RH is -1
    

    Any thoughts ?
    Sensor hookup: Gnd = Gnd , Vcc = D1, DATA = D2

    My code:

    setWatch (function(){
    digitalWrite(D1, 1);  
      var dht = require("http://www.espruino.com/modules­/DHT11.js").connect(D2);
      dht.read(function (a) {
      console.log(a);
        console.log("Temp is "+a.temp.toString()+" and RH is "+a.rh.toString());
    
        if (a.rh > 70) {
          digitalPulse(LED1, 1, [2000]);
        }
        if (a.rh >= 60 && a.rh <= 70) {
          digitalPulse(LED3, 1, [2000]);
        }
        if (a.rh < 60 && a.rh != -1) {
          digitalPulse(LED2, 1, [200, 100, 200, 100, 200, 100, 200, 100, 200]);
        }
         if (a.rh === -1) {
          digitalPulse(LED1, 1, [200, 100, 200, 100, 200, 100, 200, 100, 200]);
        }
    });
      setTimeout(function() {
      digitalWrite(D1, 0);
    }, 7000);
    }, BTN, { edge:"falling",repeat:true,debounce:50})­;
    
    
    
  • Can you check the battery voltage? Either with a meter or Puck.getBatteryPercentage().

    It looks like the minimum voltage for the DHT11 is 3v, so if the battery is even slightly run down then it won't work. You could use an external source of power for it and the Puck though - there are some 3.6v non-rechargeable lithium cells (LiPos have slightly too high a voltage) that might be perfect.

    Also the DHT11 doesn't draw huge amounts of power, but it's enough that just plugging it into a CR2032 battery will flatten it in 2 months, so it's worth bearing in mind. You could always power it from an IO pin so you can turn it on and off as needed.

  • Ahh, that is the problem. 2.92V.
    Thanks for a quick answer. I have powered it on a IO pin (D1) ;)

    I really appreciate the hard work you put in to your company. Keeping the users both up to date and supported. Thanks again Gordon.

  • Ahh - I should have read your original post properly :) There can be a small voltage drop when using the GPIOs for power, so you might get a little more life out of it when connecting it directly to VCC - but you'll have the same issues with voltage eventually.

    And thanks - it's no problem at all. It's always fun to see what people make with it :)

  • Are you talking about parasitic power supply mode - if supported by this device?... If so, there are some suggestion how to get that reliably working... see, for example, DS18B20-PAR
    1-Wire Parasite-Power Digital Thermometer
    . Looking at the parameters of DHT11 or DHT22, an Espruino pins should be able to supply the (m)Amps...

    For powering sensors by pins, take a look at conversation about GPS powered by Espruino pin(s). I would be interested to see something going in your case... as profiling the powering profile for DHT11 / DHT22.


    1 Attachment

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

DHT11 can't read

Posted by Avatar for Gustav @Gustav

Actions