Error messages with the dht code

Hi, first time user and I’ve seen this issue come up a few times, but nothing I try has fixed the issue. I have copied and paste the dht code as well as the dht.cpp and dht.h (. I have put the dht.cpp and .h files under C:\Documents\Arduino\libraries\DHT. I have loaded the library and it can be seen in the contributed library list. However when I upload the dht code I get the errors below. I can only assume its not seeing the libraries, but I cant figure out what I’m doing wrong as they seem to be there. Any ideas where I’m going wrong?
Thanks
Gerhard

DHT22_temp_and_humidity:3: error: ‘dht’ does not name a type
DHT22_temp_and_humidity.ino: In function ‘void setup()’:
DHT22_temp_and_humidity:13: error: ‘DHT_LIB_VERSION’ was not declared in this scope
DHT22_temp_and_humidity.ino: In function ‘void loop()’:
DHT22_temp_and_humidity:22: error: ‘DHT’ was not declared in this scope
DHT22_temp_and_humidity:25: error: ‘DHTLIB_OK’ was not declared in this scope
DHT22_temp_and_humidity:28: error: ‘DHTLIB_ERROR_CHECKSUM’ was not declared in this scope
DHT22_temp_and_humidity:31: error: ‘DHTLIB_ERROR_TIMEOUT’ was not declared in this scope

The dht code is
#include <dht.h>

dht DHT;

#define DHT22_PIN 5

void setup()
{
Serial.begin(9600);
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);

}

The dht.cpp and .h codes are here http://playground.arduino.cc/Main/DHTLib

Hi Gerhard

If you click on File - Preferences in the IDE, what is the full path under "sketchbook location"?

I have copied and paste the dht code as well as the dht.cpp and dht.h (. I have put the dht.cpp and .h files under C:\Documents\Arduino\libraries\DHT.

And could you post the two library files (maybe easier as attachments). I have just compiled your code OK, and could compare your library files with mine.

Regards

Ray

Hi Ray
The sketchbook location is C:\Users\gerhardw\Documents\Arduino

The library location is C:\Users\gerhardw\Documents\Arduino\libraries\DHT

Thanks
Gerhard

dht.h.ino (866 Bytes)

dht.cpp.ino (4.21 KB)

Hi Gerhard

Not sure if it is just because of attaching them to the post, but the library file names have .ino at the end. They need to be just .h and .cpp.

They have the same contents as the ones on my system.

Regards

Ray

Hi Ray, Thanks, sorted it. In windows explorer it appears as dht.h and dht.cpp and has the Arduino icon. When I looked at the properties, they are dht.h.ino (.ino = an Arduino file). I copied the code into notepad and saved as .h etc and it works! So simple in hindsight!

Thanks for your time.

Gerhard