I have been working around the following sketch for the display of humidity and temperature in the serial monitor but with no success so far. The only display I see is "DHT22 Time out error -999.0 % -999.0 C". What should I do in order to get a meaningful reading??? Please advice... I have attached herewith the .cpp and .h files of the dht library (courtesy Rob Tillaart) which I have used in the sketch.
// FILE: dht_test.ino
// AUTHOR: Rob Tillaart
// VERSION: 0.1.07
// PURPOSE: DHT Temperature & Humidity Sensor library for Arduino
// URL: http://arduino.cc/playground/Main/DHTLib
//
// Released to the public domain
//
#include <stdio.h>
#include <dht.h>
dht DHT;
//#define DHT11_PIN 4
//#define DHT21_PIN 5
#define DHT22_PIN 2
void setup()
{
Serial.begin(115200);
Serial.println("DHT TEST PROGRAM ");
Serial.print("LIBRARY VERSION: ");
Serial.println(DHT_LIB_VERSION);
Serial.println();
Serial.println("Type,\tstatus,\tHumidity (%),\tTemperature (C)");
}
void loop()
{
// READ DATA
Serial.print("DHT22, \t");
int chk = DHT.read22(DHT22_PIN);
switch (chk)
{
case DHTLIB_OK:
Serial.print("OK,\t");
break;
case DHTLIB_ERROR_CHECKSUM:
Serial.print("Checksum error,\t");
break;
case DHTLIB_ERROR_TIMEOUT:
Serial.print("Time out error,\t");
break;
default:
Serial.print("Unknown error,\t");
break;
}
// DISPLAY DATA
Serial.print(DHT.humidity, 1);
Serial.print(",\t");
Serial.println(DHT.temperature, 1);
delay(1000);
}
//
// END OF FILE
//
DHT22_4.ino (1.1 KB)
dht.cpp (4.59 KB)
dht.h (1.47 KB)
Dear Rob,
If u come across this thread, please bother to shed some light on the issues I am facing....
Hi biswa263,
Please try the 0.1.13 version of this library as the 0.1.14 is not a preferred version
see attachment
dht 0.1.13.zip (2.17 KB)
Thank You Rob,
That really nailed it......
The display now shows
DHT22, Ok, 86, 26 which is what I had expected considering the climate today....
See you later...
Hi Rob
I've just tried your 0.113 version and having the same Timeout Error using DHT22.
Any more thoughts?
Aaron
Do you use the right sized pull up resistor?
10K - tried a 4K7 also without success.
I've scoured the internet and tried various sources for code to test with. I get the same result on every test.
I have a feeling I may have a dodgy sensor!?
Hello everyone,
I´m a new user of this board here. I´ve got the same problems. It started the same way as biswa263 wrote in his first topic.
I tried the library 0.1.13 as I first downloaded the 0.1.14.
NOw I´ve got a diffrent error message :DHT22, Time out error, ovf, 0.0, 3176
I´m using a 10k resistor.
For your info. I´m playing arround with this DHT22 the whole day. I tried diffrent libraries dht sensor library 1.3.0 down to 1.1.2 or so. I tried nearly everything. But nothin ghelped.
The sensor is working fine with my raspberry pi and python skript. Values are displayed correctly. But if I switch over to the esp8266 setting (Board: ESP-01) only the wifi-connection and serial prints are working. I´m just pulling off the connection (Data-pin2 with the 10k pull-up) from my raspi and connect it to the GPIO02 pin from the ESP-01 board.
Maybe it is you who can help me?
I´m a newbie in arduino programming the esp and dht.
Please give ma a short hint or whatever could help me.
Sorry for my bad english ![:slight_smile: :slight_smile:](https://emoji.discourse-cdn.com/twitter/slight_smile.png?v=12)
Regards Thorsten
Do you have the grounds connected?
At the beginning, my DHT22 did not work with Arduino-DHT22 Library; it did not work with DHT Sensor Library; Ffinally, it worked with SimpleDHT Library. I have 2.2k pull-up with signal line, and I executed example program from the library.
Hi Guys,
@wvmarle: What do you mean with grounds connected? I think they are connected. Otherwise the sensor would not send any temp or humidity value to my raspberry pi. I´m not one hundred percent sure what you mean.
@GolamMostafa: I also tried the simpleDHT library. Just with the example programm to see the output on the serial monitor. But also I had no luck. Maybe I also should change the esp library? My thought is that the timing is not correct for the DHT. Therefore the ESP is responsible. Isn´t it?
Just wondering......
BEst regards
Thorsten
Arduino ground and sensor ground. You only mention switching data line, not power supply lines. I'm reading the DHT22 using an ESP8266 just fine; IIRC it's the Adafruit library.
Hello @wvmarle, happy easter....
Ah ok I see what you mean. You're right I just switched the data line. The ground of external power supply is not connected to the same ground of the raspi. Is that a problem? If so can I connect the both geounds together on my breadboard?
I'm not the expert in electronics.....lol
Do you also use the esp8266 as a http client? I wanna write the temperature in a database by http request. It's a local database. And whwn the esp8266 is completely autark there are no values edited. So I wanna check the output by the serial monitor. Maybe that was no good idea. In case of the diffrent grounds. But I've no idea how to get access on its outputs.
Regards Thorsten
For DHT22: that's normally connected 3.3V to Vcc of the ESP, GND to GND of ESP, signal out to a digital pin. If you don't connect at least the ground of the DHT to that of the ESP you don't have a circuit. A single wire is no circuit.
Hello @wvmarle,
I think I've to explain a bit more detailed.
1st setup:
Working good. DHT22 is giving the correct temp/hum values to the database
2nd setup:
Esp8266 working as http client (ok) but not sending the values to the database. Wired like followed:
Don't be confused DHT11 is a DHT22 and the esp8266 is a esp-01 (didn't found a better image)
Setup is completely autark. Programming esp-01 with following usb programmer with the following usb interface:
Programming via Arduino IDE.
Unfortunately I've got no glue how to access esp in this mode to see the complete url requested (for debugging)
That's why I thought to switch just the data line.
Also I thought I can generate a setup where I've got access to serial monitor via arduino ide.
In this case I can use the serial monitor when connecting data-pin from dht22 to gpio02 from esp-01.
Maybe this brings more clearance in this issue.
Regards Thorsten
Why don't you use a normal development module such as a NodeMCU or WeMOS board for development? Makes life a lot easier. Then if you really want to go extra small you can put your final project on an ESP-01 module.
Nonetheless you should be able to access the TX/RX from your PC, and program it through the Arduino IDE just the same - do remember to set your USB/TTL adapter to 3.3V, and pull low GPIO0 when starting up to get into program mode.
When I'm programming the Esp-01 I'm always pulling down the GPIO01 pin for setting the esp in program mode. So I tried many diffrent libraries. Unfortunatwly with no success.Maybe you could tell me which library for esp you are using? And which lib for dht22?
I'm trying further maybe I will have success. Could it be possible that if I try a diffrwnt lib for dht I have to delet the other one. I didn't do this is the past. Maybe this could be a mistake because the programm isnt referring to the correct lib?
Regards Thorsten
Rittermini:
Could it be possible that if I try a diffrwnt lib for dht I have to delet the other one. I didn't do this is the past. Maybe this could be a mistake because the programm isnt referring to the correct lib?
If the file names are identical... I really don't know which one the IDE will choose. I guess the first one it encounters.
I'm using the Adafruit library.