Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It desn't work with ESP8266 #6

Open
gosewski opened this issue Mar 18, 2016 · 8 comments
Open

It desn't work with ESP8266 #6

gosewski opened this issue Mar 18, 2016 · 8 comments

Comments

@gosewski
Copy link

When compiled for ESP8266, this library functions return some strange readings like:
Temperature: 3080214.00 *C
Humidity: 404527.00 %

@CuriousTech
Copy link

Uninitialized variable. In DHT.cpp, line 147. Change...
word data;
to
word data = 0;

@Lucky7Chess
Copy link

Lucky7Chess commented Aug 5, 2016

Did that actually work? Didn't work for me.......

@peterodro
Copy link

dears,
i make a trial with DHT11 and DHT22.
it is working only with DHT11, with DHT22 it shows any strange value.
I check connected DHT model with "dht.getModel()".
In both cases it shows model 1 = DHT11.
I try to manualy set for model 2 (dht.setup(2,2) or dht.setup(2, DHT22) ) but it always get any error.
Then I adapt DHT.cpp file, i manualy add line model = DHT22; into "void DHT::readSensor()"
Problem solved.
How to corectly set dht.setup() to make fix model type DHT22?

@CuriousTech
Copy link

@peterodro try adding Serial.println(DHT22); and see if it prints a 2.

The latest esp8266 SDK has trouble with uninitialized variables even though it's supposed to set them to zero. The DHT_MODEL_t enum in DHT.h is uninitialized. It should begin with AUTO_DETECT = 0 to get around the bug.

If those 2 var inits don't work, make sure it's not something else like I/O pins or hardware.

@peterodro
Copy link

i'm sure about correct connection.
In my project I put a 4pin "connector" in place of DHT, so i just plug in DHT11 and then DHT22 (both have same connection i suppose). DHT11 works ok, DHT22 shows 1.0C and 0.0%.
To be sure that DHTs are OK, i test them before on Arduino UNO board, with examples from IDE.
So HW is 100% ok.
in my program is used dht.setup(2);
So DHT connect into pin2.
I need to somethink like dht.setup(2, DHT22); or dht.setup(2, 2); but it gives error.
what is correct syntax of dht.setup() with exactly selected model?

@CuriousTech
Copy link

@peterodro It should be dht.setup(pin, DHT::DHT22); For hardware, if you're powering it at 3.3V you may need a pullup resistor if the signal line is low idle. You can also change the pinMode() in readSensor() to use INPUT_PULLUP instead of INPUT, which is a little easier.

@peterodro
Copy link

@CuriousTech
thanks
dht.setup(pin, DHT::DHT22); works

so auto detection not working in this lib, but problem solved without changing lib.

@CuriousTech
Copy link

@peterodro It looks like you're probably including 2 different DHT libraries and getting some conflicts. There's another one defining DHT22 as a different value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants