You are reading a single comment by @hygy and its replies. Click here to read the full conversation.
  • @Gordon this does not work for me. I'm using AM2302, ESP8266

    >reset()
    =undefined
     _____                 _
    |   __|___ ___ ___ _ _|_|___ ___
    |   __|_ -| . |  _| | | |   | . |
    |_____|___|  _|_| |___|_|_|_|___|
              |_| http://espruino.com
     1v85 Copyright 2016 G.Williams
    Espruino is Open Source. Our work is supported
    only by sales of official boards and donations:
    http://espruino.com/Donate
    Flash map 4MB:512/512, manuf 0xe0 chip 0x4016
    > 
    
    {
      "raw": "010000000110011011000000010011000011001­1011",
      "rh": 41.1, "temp": -30.4 }
    Temp is -30.4 and RH is 41.1
    { "err": true, "checksumError": false,
      "raw": "",
      "temp": -1, "rh": -1 }
    

    It is getting err: true, if I unplug/replug the data pin from the AM2302 then sometimes it reads like this negative value.

    This is the code what i'm using now:

    var pin=D2;
    var dht = require("https://raw.githubusercontent.c­om/espruino/EspruinoDocs/master/devices/­DHT22.js").connect(pin);
    
    setInterval(function() {
      dht.read(
        function(a){
          console.log(a);
          console.log("Temp is "+a.temp.toString()+
                      " and RH is "+a.rh.toString());
    });}, 1000);
    

    Using this is wrong to:

    var dht = require("DHT22").connect(pin);
    
About

Avatar for hygy @hygy started