rwaldron / johnny-five

JavaScript Robotics and IoT programming framework, developed at Bocoup.
http://johnny-five.io
Other
13.3k stars 1.77k forks source link

DHT11 (via i2C nano backpack) #1273

Open lezabour opened 7 years ago

lezabour commented 7 years ago

hey really having a hard time with this ;) I have the DHT11 PCB version (https://www.aliexpress.com/w/wholesale-dht11.html) Work good directly on the arduino uno(not johnny five). I used a arduino nano, to make like you describe the I2C nano backpack. i put the firmware on the nano backpack ( dht11_i2c_nano_backpack.ino)

Now it's done, but i still have no data

temperature celsius : 0 fahrenheit : 32 kelvin : 273.15 --------------------------------------

I used this code:

`board.on("ready", function() { console.log('rdy'); var multi = new five.Multi({ controller: "DHT11_I2C_NANO_BACKPACK" });

setInterval(function() {

console.log("temperature");
console.log("  celsius           : ", multi.temperature.celsius);
console.log("  fahrenheit        : ", multi.temperature.fahrenheit);
console.log("  kelvin            : ", multi.temperature.kelvin);
console.log("--------------------------------------");

console.log("Hygrometer");
console.log("  relative humidity : ", multi.hygrometer.relativeHumidity);
console.log("--------------------------------------");
}, 5000);

}); ` I dont know if i need to use a resitor (used it anyway) since i have the PCB version...

thanks for help ;)

lyzadanger commented 7 years ago

Hi, @lezabour !

Could you tell me more about your setup? What kind of board is the Nano (backpack) currently connected to physically? Is it connected to an Arduino Uno? A diagram or photo of your circuit/setup would be super helpful if you are able, also. Do you have something akin to [http://johnny-five.io/api/multi/#dht11i2cnanobackpack](this configuration)?

lezabour commented 7 years ago

Hi @lyzadanger, Thanks for your answer ;) I'm using: Nano V3.0 - ATmega 328P as backpack (with the dht11_i2c_nano_backpack.ino firmware) An arduino UNO as main controller (with Firmata on it) All is wired like in the schematic here [http://johnny-five.io/api/multi/#dht11i2cnanobackpack] 2 difference with this schematic:

So i have no data coming (always 0). I tryed:

Really don't know what do to

Thanks for your help

ghost commented 7 years ago

I'm seeing the same thing, I have the same chip but with 3 connectors ( https://www.aliexpress.com/item/1pcs-free-shipping-DHT11-Temperature-And-Relative-Humidity-Sensor-Module-PCB-for-Arduino-DIY-Starter-Kit/32631854864.html )

Also seeing temp always 0 as well as humidity.

felansu commented 7 years ago

@martip-sainsburys exactly same problem !

rwaldron commented 7 years ago

Has everyone here tried the other, newer DHT* firmware? It's also available here: https://github.com/rwaldron/johnny-five/tree/master/firmwares, in https://github.com/rwaldron/johnny-five/blob/master/firmwares/dht_i2c_nano_backpack.ino . To be clear, I have no idea if this will fix your issue, but worth a try to see what we can learn. The firmware is just using the Arduino DHT library. Can someone share the arduino C sketch that works correctly? I could just use the one given in the Arduino IDE examples, but I want to make sure I'm comparing apples to apples :)

dtex commented 6 years ago

@felansu @martip-sainsburys and @lezabour

I just want to followup and see if any of y'all were able to try the other firmware that @rwaldron suggested.

drprime commented 6 years ago

Have this problem to with dht22. Trying Uno+nano, mega + nano. Celsium temperature is 0 firware dht_i2c_nano_backpack.ino Without johny-five working fine(test scatch from dht lib) And i have another question. How to connect 2 or more (i need 6) sensors dht22 using johny-five?

dnviti commented 5 years ago

The only way to make it work is to define the DHTTYPE and the DHTPIN as preprocessor directive because you're probably using the default adafruit DHT library which ONLY SUPPORT declaring pin and type like i said before. PS: on the other hand you have to define type and pin for every arduino backpack you use. PPS: the Johnny Five team should publish their dht library (or the one they used...), this piece of software is strictly dependent from it!!!

Below you can find the working code with comments for DHTTYPE switching:

dht_i2c_nano_backpack_adafruit.zip

Cheers.

NguyenHoangSon96 commented 5 years ago

So what is the solution guys, i have the same proplem

marti2221 commented 5 years ago

I have the same problem as well, would love to hear some more ideas

TooFast4ya commented 5 years ago

Same for me :(

EduAir commented 4 years ago

same for me ! Any idea?

derplarsen commented 3 years ago

This actually works.. i noticed the values were correct when you subract 1000 from C, 1800 from F, and 1000 from K :) 🤷‍♂️

  temperature.on("data", function() {
    console.log("celsius: %d", this.C-1000);
    console.log("fahrenheit: %d", this.F-1800);
    console.log("kelvin: %d", this.K-1000);
  });