-
• #2
Thanks! Someone's actually had a go at a better module, which is here - I didn't want to have two conflicting ones, but hopefully at some point I'll merge that one into the normal DHT22 module.
You should be able to
require("https://github.com/CanyonCasa/EspruinoDocs/blob/master/devices/HTxx.js")
and try the new one out though.I only have a DHT11 to test with, but perhaps if I post a tweaked version of the original up you have have a test with that?
-
• #3
I found through lots of debugging that the signal was getting cut off most of the time at about the 33rd/34th bit, which meant the checksum rarely matched. I would make some changes to the library, but I don't know if this is just my module that isn't working how it should or if it's common for all of them.
I have seen issues where it gave out after 33/34 bits, but that was on a board that had only 32-level event queue, and when @Gordon increased it, the behavior changed.
I never encountered that issue when I was writing the DHT22 module code (also, 50ms or 150ms shouldn't matter - either of those are much longer than the signal takes to transmit. (that code is my fault, though @Gordon was an accessory)
If there are issues, it would be great if we could figure out how to fix the existing DHT22 module to work with them?
-
• #4
I'm not quite sure what the new HTxx module is trying to fix, hence not merging it in right away. It's definitely a bonus if one module can do all the different types though.
These troubles could well be a side-effect of people using Espruino on an ESP8266 where the event queue might be smaller?
I'll start a new thread with some ideas for a common module that will hopefully be compatible with everything, and is a bit cleaner and faster.
-
• #5
Just to add, the new 'general purpose' module actually doesn't work on my DHT11, when the old one does :)
-
• #6
Post on new module: http://forum.espruino.com/conversations/281522/
-
• #7
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
2 Attachments
-
• #8
As that's not one of the Espruino boards, maybe try posting on the ESP8266 section of the forum? I believe some of the folks on there may have encountered some issues with ESP8266 and these sensors before.
Just a quick note to say that if anyone else has trouble getting an AM2302 to work with the DHT22 library (getting -1 returned most of the time), try changing the timeout on this.to50ms to a higher number. 150ms works for the module I have and now it returns a correct value almost all the time.
I found through lots of debugging that the signal was getting cut off most of the time at about the 33rd/34th bit, which meant the checksum rarely matched. I would make some changes to the library, but I don't know if this is just my module that isn't working how it should or if it's common for all of them.