"DHT does not name a type"

Hi all.

I know that this has cropped up many times before, no matter what i do i cannot get rid of the error, i have tried many of the so called DHT22 libraries, but to no avail, i am assuming that this is a library problem, can any one help me solve this error?

//Sketch for Atmosphere Controlled Guitar Cabinet


#include <Wire.h> 
#include <LCD.h>

 
#define DHT1PIN 4     // what pin we're connected to
#define DHT2PIN 5
 
#define DHTTYPE DHT22   // DHT 22 (AM2302) 
#define DHTTYPE DHT22   // DHT 22  (AM2302)

DHT dht(DHTPIN,DHTTYPE);

#define I2C_ADDR 0x27 //ALWAYS USE THIS WITH LCD I2C and Address 0x27
#define BACKLIGHT_PIN 3
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7
LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);

  float h1 = dht1.readHumidity();
  float t1 = dht1.readTemperature();
  float h2 = dht2.readHumidity();
  float t2 = dht2.readTemperature();

 
void setup()
{ 
  Serial.begin(9600); 
  Serial.println("DHTxx test!");
  lcd.begin(20,4);
  lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
  lcd.setBacklight(HIGH);
 
  dht1.begin();
  dht2.begin();
}
 
void loop() 
{
 
// check if returns are valid, if they are NaN (not a number) then something went wrong!
  if (isnan(t1) || isnan(h1)) {
    Serial.println("Failed to read from DHT #1");
  } else {
    Serial.print("Humidity 1: "); 
    Serial.print(h1);
    Serial.print(" %\t");
    Serial.print("Temperature 1: "); 
    Serial.print(t1);
    Serial.println(" *C");
  }
  if (isnan(t2) || isnan(h2)) {
    Serial.println("Failed to read from DHT #2");
  } else {
    Serial.print("Humidity 2: "); 
    Serial.print(h2);
    Serial.print(" %\t");
    Serial.print("Temperature 2: "); 
    Serial.print(t2);
    Serial.println(" *C");
  }
  Serial.println();

  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Room Temp : ");
  lcd.print(temp);
  lcd.print(" ");
  lcd.print((char)223);
  lcd.print("C");
  lcd.setCursor(0,1);
  lcd.print("Room Hum  : ");
  lcd.print(hum);
  lcd.print(" %");

  lcd.setCursor(0,2);
  lcd.print("Cab Temp  : ");
  lcd.print(temp);
  lcd.print(" ");
  lcd.print((char)223);
  lcd.print("C");
  lcd.setCursor(0,3);
  lcd.print("Cab Hum   : ");
  lcd.print(hum);
  lcd.print(" %");
  

  delay (2000);
}

i have tried many of the so called DHT22 libraries

...but not in this sketch.

  float h1 = dht1.readHumidity();
  float t1 = dht1.readTemperature();
  float h2 = dht2.readHumidity();
  float t2 = dht2.readTemperature();

 
void setup()

What do you expect those variables will contain?
What is "dht1"?
What is "dht2"?

The code you posted does not include any DHT libraries so it's not surprising that you get the error. Also you need to sort out the pins...you have DHT1PIN and DHT2PIN then you're trying to use DHTPIN which doesn't exist.

The code looks like it is based on the DHT sensor library by Adafruit. Is that one of the many so-called libraries that you have tried?

Steve

Hi Steve, thanks for replying.

I defined the sensors as they are DHT1 is the first sensor, DHT2 is the second sensor, what should i have written there ?

I think i have tried 3 or 4 libraries, adafruit being one, i got one from github, and another from the ARDUINO site.

Regards

Ray

TMFKAAWOL

Are you saying my "float" sketch is wrong??

DHT 1 & DHT 2 I expect them to do what they are supposed to do, measure temperature & humidity in two different places.

gresleyman:
TMFKAAWOL

Are you saying my "float" sketch is wrong??

Yes, and so is the compiler.

DHT 1 & DHT 2 I expect them to do what they are supposed to do, measure temperature & humidity in two different places.

Just the once, and before they've been initialised?

gresleyman:
I defined the sensors as they are DHT1 is the first sensor, DHT2 is the second sensor, what should i have written there ?

And then you said you only had one sensor

DHT dht(DHTPIN,DHTTYPE);

and it's pin was called DHTPIN.

Two sensors...two DHT class intialisations.

Steve

Take a look at the code here for ideas.