Open ADiea opened 9 years ago
Hi @ADiea, I am using a SainSmart Mega2560 and a SainSmart AM2302 sensor (DHT22 variant), but your library sadly returns 0.00 for temp and humidity. It probably connects fine, because when it's disconnected, it reports an error. Secondly, the lib from @RobTillaart gives me normal values.. I still like yours better, because it has dewpoint calculation :)
Hi @Maxr1998 please enable debug in dht.h and tell me what you get on the console. I also use the AM2302 sensor for testing.
#define DHT_DEBUG 1
Thanks
Make sure to use the latest code, I fixed some cornercases
@ADiea this is my log output atm:
libDHT: Detected DHT-22 compatible sensor.
40
0, 0, 0, 0, 0 =? 0
Temperature: 0.00
Humidity: 0.00
Dew point: nan
Here's my code, just to be sure:
#include "DHT.h"
#define DHTPIN 5
TempAndHumidity th;
DHT dht(DHTPIN);
void setup() {
Serial.begin(9600);
Serial.println("DHT22 test");
dht.begin();
}
void loop() {
delay(2000);
if(!dht.readTempAndHumidity(th)) {
Serial.print("Failed to read from DHT sensor for reason: ");
switch(dht.getLastError())
{
case errDHT_Timeout:
Serial.print("TIMEOUT (no sensor?) \n");
break;
case errDHT_Checksum:
Serial.print("CHECKSUM (are cables secured?) \n");
break;
case errDHT_Other:
Serial.print("UNKNOWN \n");
break;
};
return;
}
Serial.print("Temperature: ");
Serial.println(th.temp);
Serial.print("Humidity: ");
Serial.println(th.humid);
double dp = dht.getDewPoint(DEW_ACCURATE);
Serial.print("Dew point: ");
Serial.println(dp);
}
Also, it seems the Arduino IDE doesn't know debugf(), or is my Version just to old (1.5.6 r2)?
Looking at your sensor's picture on the internet it seems it already has a pullup....
In dht.cpp try replacing the line
PULLUP_PIN(m_kSensorPin);
with
pinMode(m_kSensorPin, INPUT);
and write back if this helps...
@ADiea Nope, sorry, still the same. And yes, it already has pullup resistor, I am using this one.
Unfortunately I have no other idea at the moment I will try comparing the code to Rob's when I have some free time.
Ok, thanks for your efforts though :)
Any updates?
Nothing yet sorry. I am planning a clean-up and a bit of restructuring of the code to make it simpler but not on the priority list unfortunately - so can't promise anything yet
Hi guys and girls, This lib needs people with some spare time and Arduino hardware to help test it. Comments are welcome Cheers!