DHT does not name a type

Getting an error message when attempting to verify an Arduido sketch code. Don’t understand why I’m getting error.

code is :=====================================
#include <DHT.h>
#define dht_apin A0 // Analog Pin sensor is connected to

dht DHT;

===========================================

Error is ‘DHT’ does not name a type. Can anyone help?

Likely the DHT.h library is not where it's expected to be, in your sketchbook /libraries path.

THEKNOTGUY:
Getting an error message when attempting to verify an Arduido sketch code. Don’t understand why I’m getting error.

code is :=====================================
#include <DHT.h>
#define dht_apin A0 // Analog Pin sensor is connected to

dht DHT;

===========================================

Error is ‘DHT’ does not name a type. Can anyone help?

I am pretty sure the Adafruit example program does not have dht DHT;

I would expect the class name to be DHT and therefore the declaration to be

DHT dht;

You need to check the class declaration in the header file.

Thanks for the pointers. Will work on the issue.

use #define DHTPIN 2
and #define DHTTYPE DHT11
then DHT dht(DHTPIN,SHTTYPE);

Are you using the same version of the DHT library that code was meant for?

I think there are two versions with the same name and different API.

SD-solar: use #define DHTPIN 2 and #define DHTTYPE DHT11 then DHT dht(DHTPIN,SHTTYPE);

SHTTYPE s/b DHTTYPE , correct?

A small portion of what I use before setup:

// Uncomment whatever DHT type you're using!
//#define DHTTYPE DHT11   // DHT 11 
#define DHTTYPE DHT22   // DHT 22  (AM2302)
//#define DHTTYPE DHT21   // DHT 21 (AM2301)

//Define Arduino input pin
#define DHTPIN 2

There are other ways to go about getting the same results.

Pretty old thread?

Ron

bagheera2: SHTTYPE s/b DHTTYPE , correct?

Yeah. Probably someone typing code from memory and/or on their phone; code posted in answers is generally not warrantied against typos, since people answering questions are often typing from memory, rather than actually testing the code, as that's too much work when throwing out quick answers. 'tis what you get for free support from strangers on the internet :-P