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() {
lcd.begin(16,2);
lcd.setCursor(0,1);
Serial.begin(9600);
delay(500);
Serial.println("DHT11 Humidity & temperature Sensor\n\n");
delay(1000);
}
void loop() {
Serial.print("Current humidity = ");
Serial.print(DHT.humidity);
Serial.print("% ");
Serial.print("temperature = ");
Serial.print(DHT.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
DHT.read11(dht_apin);
^~~
exit status 1
'DHT' does not name a type
Thank you for taking the time to look through, I really appreciate it