You are reading a single comment by @ClearMemory041063 and its replies. Click here to read the full conversation.
  • Running a PICO V1.87
    This code

    //DHT22.js
    //10Oct2016
    
    var dpin=B3;
    var F;
    var H;
    
    var dht = require("DHT22").connect(dpin);
    
    setInterval(function () {
    //  dht.read(function (a) {});
      dht.read(function (a) {
     F=(a.temp+40)*9/5-40;
     H=a.rh;
      console.log("Temp is "+F.toString()+" and RH is "+H.toString());
    });
    }, 1000);
    

    produces the following output

    >echo(0);
    =undefined
    Temp is 30.2 and RH is -1
    Temp is 30.2 and RH is -1
    Temp is 30.2 and RH is -1
    Temp is 30.2 and RH is -1
    Temp is 71.6 and RH is 52
    Temp is 30.2 and RH is -1
    Temp is 30.2 and RH is -1
    Temp is 30.2 and RH is -1
    Temp is 71.6 and RH is 51.6
    Temp is 30.2 and RH is -1
    Temp is 71.78 and RH is 51.6
    Temp is 30.2 and RH is -1
    Temp is 71.78 and RH is 51.6
    >clearInterval();
    =undefined
    

    But this code

    //DHT22.js
    //10Oct2016
    
    var dpin=B3;
    var F;
    var H;
    
    var dht = require("DHT22").connect(dpin);
    
    setInterval(function () {
      dht.read(function (a) {});
      dht.read(function (a) {
     F=(a.temp+40)*9/5-40;
     H=a.rh;
      console.log("Temp is "+F.toString()+" and RH is "+H.toString());
    });
    }, 1000);
    

    Produces this output

    >echo(0);
    =undefined
    Temp is 71.78 and RH is 51.6
    Temp is 71.96 and RH is 51.7
    Temp is 71.78 and RH is 51.6
    Temp is 71.78 and RH is 51.6
    Temp is 71.78 and RH is 51.6
    Temp is 71.78 and RH is 51.6
    Temp is 71.78 and RH is 51.6
    Temp is 71.6 and RH is 51.5
    Temp is 71.78 and RH is 51.6
    Temp is 71.78 and RH is 51.8
    Temp is 71.78 and RH is 51.8
    >clearInterval();
    =undefined
    > 
    

    Is there something missing in the module code?
    Pin initialization?
    A bit?

About