working fine on ESP, build version see test output
comments: I prefer a fixed result format, e.g. 999.9
pin=D4;
// latest version 14-Jan-2016 16:09
var dht22 = require("DHT22").connect(pin);
var dht22_read_test = function() {
dht22.read(
function(a){
console.log("Temp is "+a.temp.toString()+
" and RH is "+a.rh.toString());
});};
setInterval(dht22_read_test,5000);
/* test output
1v84.tve_master_f35ac96 Copyright 2016 G.Williams
WARNING: the esp8266 port is in beta!
Flash map 4MB:512/512, manuf 0xe0 chip 0x4016
>echo(0);
=undefined
Temp is 19.9 and RH is 45.7
Temp is 19.9 and RH is 45.8
Temp is 19.9 and RH is 45.6
Temp is 19.9 and RH is 45.6
Temp is 19.9 and RH is 45.6
Temp is 19.9 and RH is 46
Temp is 19.9 and RH is 43.1
Temp is 19.8 and RH is 42.3
Temp is 19.8 and RH is 40.8
Temp is 19.7 and RH is 40.9
Temp is 19.5 and RH is 41.3
Temp is 19.4 and RH is 41.3
Temp is 19.2 and RH is 39.5
Temp is 19.1 and RH is 40.3
Temp is 18.9 and RH is 43.7
Temp is 18.7 and RH is 44.2
Temp is 18.2 and RH is 36.9
Temp is 17.9 and RH is 37.2
Temp is 17.7 and RH is 39.1
Temp is 17.4 and RH is 36.7
Temp is 17 and RH is 36.4
Temp is 16.6 and RH is 37.4
Temp is 16.3 and RH is 38.9
Temp is 15.9 and RH is 41.1
Temp is 15.6 and RH is 42
Temp is 15.3 and RH is 41
Temp is 14.8 and RH is 42.9
Temp is 14.8 and RH is 42.9
Temp is 14.6 and RH is 43.5
*/
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
working fine on ESP, build version see test output
comments: I prefer a fixed result format, e.g. 999.9