Issues using DHT11 module

Hi Everyone! im trying to program a DHT11 temperature and humidity sensor to display data on an lcd. I am using an Uno R3. I keep getting an error saying "DHT does not name a type" the library I am using is dhtlib. here is the code, and yes, I'm aware the lcd code is in notes, just troubleshooting the dht11:


<#include <dht.h>
#include <LiquidCrystal.h>;

#define DHTPIN 2                            //defines what digital pin is used by sensor
#define DHTTYPE DHT11                       //tells the arduino that we are using a dht11 and not a dht22

DHT dht (DHTPIN, DHTTYPE);                  //initializes dht sensor
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);      //what pints the lcd uses



void setup()
{
  Serial.begin(9600);
  //lcd.begin(16, 2);
  
  dht.begin();
  

}

void loop()
{
  delay(10000);                              //time between data update

  float t = dht.readTemperature();           //reads temperature in celcius
  float h = dht.readHumidity();              //reads humidity data
  float hic = dht.commputeHeatIndex(t, h);

//serial monitor display for troubleshooting

  Serial.println("temperature: ");          
  Serial.print(t);
  Serial.print("*C");
  Serial.println("Humidity: ");
  Serial.print(h);
  Serial.print("%");
  Serial.println("Heat Index: ");
  Serial.print(hic);

//lcd display
  /*lcd.setCursor(0,0);
   * lcd.print("T= ");
   * lcd.setCursor(2,0 );
   * lcd.print(t);
   * lcd.setCursor(4,0);
   * lcd.print("*C");
   * lcd.setCursor(0,1);
   * lcd.print("H= ");
   * lcd.setCursor(2,1);
   * lcd.print(h);
   * lcd.setCursor(4,1);
   * lcd.print"%");
   * lcd.setCursor(8,1);
   * lcd.print("HI= ");
   * lcd.print(hic);
   */
  
}

When I look at this example, it looks like the class name is dht in lower case.

[edit]

You probably used an example sketch that does not match the library used.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.