temperature humidity sensor library problems

My first post so I hope I don't stuff up!

Attempting to get a sketch and library for DHT11 temp and humidity sensor, obtained from Arduino Playground - DHT11Lib, working .

I am very new to the arduino but have a reasonable programming background so I am pretty sure I am not makeing to many simple mistakes

When I attempt to load the sketch I get a complie error

DHTtest1:49: error: 'dht11' does not name a type
DHTtest1.cpp: In function 'void loop()':
DHTtest1:66: error: 'DHT11' was not declared in this scope

the offending line of code appears to be

dht11 DHT11;

surrounding code is

#include <dht11.h>

dht11 DHT11;

#define DHT11PIN 2

This is where I come unstuck. I don't understand the syntax. I am new to C++ and arduino but have a reasonable background in other languages to work my way through it and learn what I need to learn. The problem is I can't seem to find the right terminology to swat up on the meaning of "dht11 DHT11;" and why it is incorrect. It appears to reassign object dht11 ( which is what the library files are called) to DHT11 as this is how the object is referenced elsewhere in the sketch eg "int chk = DHT11.read(DHT11PIN);"

If anyone can help me understand what is going wrong and what I need to search for to understand the syntax and sort it out for myself it would be greatly appreciated.

Thanks in advance

When I attempt to load the sketch I get a complie error

DHTtest1:49: error: 'dht11' does not name a type
DHTtest1.cpp: In function 'void loop()':
DHTtest1:66: error: 'DHT11' was not declared in this scope

Is this the ONLY error you get? Nothing about not being able to open the include file? Did you scroll up in the error window?

The problem is I can't seem to find the right terminology to swat up on the meaning of "dht11 DHT11;" and why it is incorrect.

The line in question is creating an instance of the class, dht11, calling that instance DHT11.

The error seems to indicate that the library is not installed correctly. Where did you place the dht11.cpp and dht11.h file?
About installing libraries - http://www.arduino.cc/en/Hacking/Libraries -

Optionally you could try - Arduino Playground - DHTLib - that lib supports the DHT22 too.

thanks for the replies.

I followed the instructions on installing libraries carefully - Thanks of the hacking reference - it might give me a better instruction but I believe I have got the name and location right. The only thing is, as instructed, I have named the library folder DHT11. I tried naming it dht11 to see if it was case sensitive but that meant the library wasn't rrecognised at all. I will check name through all the files to make sure nothing is wrong. There were some other errors in the code posted on the web which I could fix. Maybe ther are some more subtle errors.

Yes the 3 lines of error were the only lines in the error window.

"The line in question is creating an instance of the class, dht11, calling that instance DHT11." - I figured this is what it was doing - as I said I ma not familar with the syntax. I guess I look up "how to create an instance of a class" to make sure I get the syntax and names correct.

Thanks for the help. I will follow up on the leads you gave me. Any further suggestion will be appreciated.

Note that all instances of the IDE must be shut down before new libraries are seen. If a lib is installed correctly the IDE can do from the menu:
-> SKETCH -> IMPORT LIBRARY -> DHT11

and insert an #include statement

Can you post the code used?

Thank you for the reply.

Yes I had shut dowma nd reopened the IDE andthe library was visible in the menu.

After spending quite a bit of time chasing down what could be wrong I found a different version of the code at http://arduino-info.wikispaces.com/DHT11-Humidity-TempSensor. This has .h and .ccp files al ready compiled. I swapped these files for the one I had and it worked first time. I am not sure what the problem was but I am pretty sure that I had the names or versions or somthin like that wrong. Being new to the language I just couldn't spot the problem.

I won't mention that even though the sketch loaded the sensor didn't appear to work - that is another problem :slight_smile:

One final thing I am struggling with. All of the tutorials and reference I have found on creating libraries simple say save the .h and .ccp file to the library folder. Lots of detail about what needs to be in the files but very vague on how to create them. I guess - but I don't actually know - that you write, copy paste, whatever a new sketch window and then save as to a .h or .ccp file, then go into the directory and remove the .pde that get tacked on the end. Is this approach correct?