-->
Page 1 of 1

Strange behaviour of DHT22 humidity sensor (crazy numbers)

PostPosted: Sun Nov 15, 2015 5:28 pm
by Gawan
Hi,

I am using a ESP8266 SP12E devkit V2 and want to transmit values from my AM2302 DHT22 temp. and humid. sensor.

The sketch itself works fine (output to serial), but as soon as I add one additional line (that has nothing to do with DHT22 or the humidity var) its getting crazy ...

This is how it works:

Code: Select all
void loop()
{
  delay(dht.getMinimumSamplingPeriod());
  float humidity = dht.getHumidity();
  float temperature = dht.getTemperature();

  Serial.println(String(millis()));
//  Serial.println("Uptime: " + String(millis()/60000) +" min  " + String(millis()/1000) + " sec");
 
  Serial.print(humidity, 1);
  Serial.print("\t\t");
  Serial.println(temperature, 1);


In this case the output looks like:
........
WiFi connected
Server started
10.0.0.29
6811
45.2 24.2
8816
45.2 24.2


You can see this one line that is commented out.

As soon as I comment it in:

Code: Select all
void loop()
{
  delay(dht.getMinimumSamplingPeriod());
  float humidity = dht.getHumidity();
  float temperature = dht.getTemperature();

  Serial.println(String(millis()));
  Serial.println("Uptime: " + String(millis()/60000) +" min  " + String(millis()/1000) + " sec");
 
  Serial.print(humidity, 1);
  Serial.print("\t\t");
  Serial.println(temperature, 1);


this is what I get:

........
WiFi connected
Server started
10.0.0.29
6811
Uptime: 0 min 6 sec
6553649.0 24.2
8816
Uptime: 0 min 8 sec
6553649.0 24.2


The humidity value is just scrap.
I have no idea how this can happen ...
Does anyone have a hint for me ?

BR
Gawan

Re: Strange behaviour of DHT22 humidity sensor (crazy number

PostPosted: Fri Dec 04, 2015 3:26 am
by Courty
Check the sensor type declaration at the top. I did this just yesterday and if you have the wrong one it works but gives rubbish values

Courty

Re: Strange behaviour of DHT22 humidity sensor (crazy number

PostPosted: Fri Dec 04, 2015 12:42 pm
by Venkatesh
The library is very important. Some of the DHT library won't work correctly. Set the correct DHT in library constructor. See examples that come with library itself.

Re: Strange behaviour of DHT22 humidity sensor (crazy number

PostPosted: Mon Dec 07, 2015 5:29 am
by GengusKahn
Gawan wrote:Hi,

I am using a ESP8266 SP12E devkit V2 and want to transmit values from my AM2302 DHT22 temp. and humid. sensor.

The sketch itself works fine (output to serial), but as soon as I add one additional line (that has nothing to do with DHT22 or the humidity var) its getting crazy ...

This is how it works:
................................

this is what I get:

........
WiFi connected
Server started
10.0.0.29
6811
Uptime: 0 min 6 sec
6553649.0 24.2
8816
Uptime: 0 min 8 sec
6553649.0 24.2


The humidity value is just scrap.
I have no idea how this can happen ...
Does anyone have a hint for me ?

BR
Gawan



Hi there, this DHT library uses strict timing when the void from the library is run, use an interrupt driven library, try searching the github....(the line is having an effect on timing).....

https://github.com/rDuinoStar/rDHT11--DHT11-Arduino-Lib

I have used this when there have been "issues".......