DHT dht; 'DHT' does not name a type ERROR

Hi everyone,

This is one of my first projects, so I'm a total newbie. I trying to use a DHT11 sensor and read the temperature and humidity and view this information on the serial monitor. However, I keep getting the error DHT dht; 'DHT' does not name a type. The guide I was going off gave me the DHT library but I'm still having trouble with it. Here's my code

#include <dht.h>

#include <LiquidCrystal.h>

LiquidCrystal lcd(1, 2, 4, 5, 6, 7);

#define dht_apin A0

DHT dht;

void setup() {

  Serial.println("DHT11 Humidity & temperature Sensor\n\n");

void loop() {

    Serial.print("Current humidity = ");
    Serial.print("%  ");
    Serial.print("temperature = ");
    Serial.println("C  ");
    delay(5000);//Wait 5 seconds before accessing the sensor again.


and here is the error:

Test_2_Sensor___LCD:10:1: error: 'DHT' does not name a type
 DHT dht;
/Users/Charlie/Documents/Arduino/Test_2_Sensor___LCD/Test_2_Sensor___LCD.ino: In function 'void loop()':
Test_2_Sensor___LCD:25:3: error: 'DHT' was not declared in this scope
exit status 1
'DHT' does not name a type

Thank you for taking the time to look through, I really appreciate it

DHT is the type, the variable is called dht, e.g.


Please, provide a link to dht.h Library.


https://www.brainy-bits.com/dht11-tutorial/ the download is at the bottom of the page

Please make sure that you install a correct library. You can see how to install library in Arduino - DHT tutorial

I would recommend downloading a great DHT library by Adafruit in library manager:

Be aware that most DHT libraries use blocking code. Have a close look if you plan to do more than one thing at a time.

What is blocking code?

What is blocking code?

Code that prevents anything else happening whilst it runs

What is blocking code?

For example:


is a blocking code; where, the MCU is prevented from executing any other task until the stipulated 1000 ms time has elapsed. Even, an interrupt request signal is unable to bring the MCU out of the waiting loop.