-
Maybe this help
DH11 VCC connected to board 3.3v
DH11 DATA connected to board D2 (GPIO04)
DH11 GND connected to board Gecho(1); // Init ESP8266 var ESP8266 = require("ESP8266"); //ESP8266.setLog(2); //ESP8266.printLog(); E.setClock(80); var dht = require("DHT11").connect(D4); setWatch(function(e){ console.log(e.time - e.lastTime); }, D4, {repeat: true, edge:"both"}); var dht2 = function(){ dht.read( function(a){ console.log(a); }); }; Result: >dht2() 109002> > jshCanWatch: pin=4 109002> < jshCanWatch = true =undefined >109526> > jshCanWatch: pin=4 109526> < jshCanWatch = true 110048> > jshCanWatch: pin=4 110048> < jshCanWatch = true 110573> > jshCanWatch: pin=4 110574> < jshCanWatch = true 111097> > jshCanWatch: pin=4 111098> < jshCanWatch = true 111620> > jshCanWatch: pin=4 111621> < jshCanWatch = true 112142> > jshCanWatch: pin=4 112142> < jshCanWatch = true 112664> > jshCanWatch: pin=4 112664> < jshCanWatch = true 113186> > jshCanWatch: pin=4 113186> < jshCanWatch = true 113711> > jshCanWatch: pin=4 113711> < jshCanWatch = true { "err": true, "checksumError": false, "raw": "0100", "temp": -1, "rh": -1 }
Firmware latest:
1v87.223 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
-
On Arduino all is working
[#include](http://forum.espruino.com/search/?q=%23include) "DHT.h" [#define](http://forum.espruino.com/search/?q=%23define) DHTPIN 0 //DHT dht(DHTPIN, DHT22); DHT dht(DHTPIN, DHT11); void setup() { Serial.begin(9600); dht.begin(); } void loop() { delay(2000); float t = dht.readTemperature(); if (isnan(t)) { Serial.println("Error"); return; } Serial.print(t); }
-
Ohh.
>console.log(NodeMCU.D5) D14
this is GPI14
My script
// Init ESP8266 var ESP8266 = require("ESP8266"); E.setClock(80); var dht = require("DHT11").connect(D14); //NodeMCU D5 var dht2 = function(){ dht.read( function(a){ console.log(a); },10); }; dht2(); { "err": true, "checksumError": false, "raw": "0100", "temp": -1, "rh": -1 }
-
-
But result Temp is -1 and RH is -1
echo(1); // Init ESP8266 var ESP8266 = require("ESP8266"); ESP8266.setLog(2); ESP8266.printLog(); E.setClock(80); var dht = require("DHT11").connect(D14); //GPIO14 NodeMCU is pin D5 //setWatch(function(e){ // console.log(e.time - e.lastTime); //}, D14, {repeat: true, edge:"both"}); var dht2 = function(){ dht.read( function(a){ console.log("Temp is "+a.temp.toString()+" and RH is "+a.rh.toString()); }); return true; }; dht2();
-
Yes, need Http server run after WiFi getting IP address
// Init WiFi Networks wifi.setHostname("my1"); wifi.connect("xxx", {password:"xxx"}, function(err){ setTimeout(function(){ console.log("connected? err=", err, "info=", wifi.getIP()); // Init Your Http Server Init(); },5000); }); wifi.stopAP(); wifi.save();
-
-
I connect by this diagram to other my board D1 Wemos do not working in ESPRUINO
from this link https://hackaday.io/project/10498-carontepass-open-access-control
-
-
-
var wifi = require("Wifi"); var dht = require("DHT22").connect(D0); // GPIO4 var lastDhtData ="none"; // Init WiFi Networks wifi.setHostname("my1"); wifi.connect("XXX", {password:"XXX"}, function(err){ console.log("connected? err=", err, "info=", wifi.getIP()); }); wifi.stopAP(); wifi.save(); function init() { initServer(); //setInterval(function(){ console.log(process.memory()); }, 100000); //require("ESP8266").setLog(2); } function initServer() { var http = require("http"); console.log("Initalizing server instance..."); // Create Http Answer http.createServer(function(req, res){ var request = url.parse(req.url, true); var action = request.query; res.writeHead(200, {'Content-Type': 'text/html'}); res.write('<html><head></head><body>'); res.write(lastDhtData); res.end('</body></html>'); }).listen(80); } // Get data from sensor every 1 minut setInterval(function(){ dht.read(function (a) { lastDhtData = a.temp.toString()+","+a.rh.toString(); }); },60000); // Send to server every 10 minut setInterval(function(){ postToServer(lastDhtData); },600000); function postToServer(data){ var options = { host: 'MAINLINK', port: '80', path:'/event', method:'POST', headers: { "Content-Type":"application/json", "Content-Length":data.length } }; require("http").request(options, function(res){ var d = ""; res.on('data', function(data) { d+= data; }); res.on('close', function(data) { console.log("Closed: "+d); }); }).end(data); } E.on('init', function() { init(); }); /* setWatch(function(e){ console.log(e.time - e.lastTime); }, D1, {repeat: true, edge:"both"}); */
-
Last question i read data from this sensor AM2301
and see ( Temp is -1 and RH is -1 )All connected to GPIO D1.
Code from examples: dht.read(function (a) {console.log("Temp is "+a.temp.toString()+" and RH is "+a.rh.toString());});
My example programm:
var wifi = require("Wifi");
var dht = require("DHT22").connect(D1);wifi.connect("xxx", {password:"xxx"}, function(err){
console.log("connected? err=", err, "info=", wifi.getIP());
});
wifi.stopAP();wifi.save();
function readTemp(){
dht.read(function (a) {console.log("Temp is "+a.temp.toString()+" and RH is "+a.rh.toString());});
}Thanks all .. this is my problem... i connect in my board D1 and Read from programm. D1.. But realy all pinout is other..
Example: ESPRUINO => D0 is my board => D3 -- GPIO0
-
-
Yes sorry, this is NodeMcu V3 4M ESP8266, i Flash
All WORK iN XUBUNTU.
First STEP1.
./esptool.py --port /dev/ttyUSB0 erase_flash
esptool.py v1.2-dev
Connecting...
Running Cesanta flasher stub...
Erasing flash (this may take a while)...
Erase took 9.2 secondsNEXT..
./esptool.py --port /dev/ttyUSB0 --baud 9600 write_flash --flash_freq 80m --flash_mode qio --flash_size 32m 0x0000 boot_v1.6.bin 0x1000 espruino_esp8266_user1.bin 0x3FC000 esp_init_data_default.bin 0x3FE000 blank.bin
esptool.py v1.2-dev
Connecting...
Running Cesanta flasher stub...
Flash params set to 0x004f
Writing 4096 @ 0x0... 4096 (100 %)
Wrote 4096 bytes at 0x0 in 4.3 seconds (7.6 kbit/s)...
Writing 471040 @ 0x1000... 471040 (100 %)
Wrote 471040 bytes at 0x1000 in 489.9 seconds (7.7 kbit/s)...
Writing 4096 @ 0x3fc000... 4096 (100 %)
Wrote 4096 bytes at 0x3fc000 in 4.3 seconds (7.6 kbit/s)...
Writing 4096 @ 0x3fe000... 4096 (100 %)
Wrote 4096 bytes at 0x3fe000 in 4.3 seconds (7.6 kbit/s)...
Leaving...and photo Web IDE do not work
-
I in This sensor have resistor. Interesting in
Arduino working,
NodeMCU + LUA working,
Espruino+JavaScript do not working.