DHT11 Error Code With Arduino Uno

I don't know how to fix this. It seems like I did it correctly...

Giving me an error saying 'DHT' was not declared in this scope

const int DHT11_PIN = 2;

void setup() {
  Serial.begin(9600);
}

void loop() {

  int chk = DHT.read(DHT11_PIN);
  switch (chk) {
    case DHTLIB_OK:
      Serial.print("");
      break;
    case DHTLIB_ERROR_CHECKSUM:
      Serial.print("");
      break;
    case DHTLIB_ERROR_TIMEOUT:
      Serial.print("Time out error");
      break;
    default:
      Serial.print("");
      break;
  }
  delay(500);
  // view data
  Serial.print("Temperature:");
  Serial.print(DHT.temperature, 1);
  Serial.print("°");
  Serial.print("C ");
  Serial.print("Humidity:");
  Serial.print(DHT.humidity, 1);
  Serial.println("%");
  delay(300);  // wait 300 ms
}

it would probably work better if you include the DHT library... (and make sure it's installed)

have this at the start of the file

#include <dht.h>

as in the examples


please, please never ever again post pictures of text... Not only they are not readable nor usable directly for copy&paste but they use up lots of storage and internet bandwidth which contributes to polluting the planet.

➜ do your part and do yourself a favour and please read How to get the best out of this forum and modify your post accordingly (including code tags and necessary documentation for your ask).

Thanks!

Please read the forum’s best practices and fix your first post (click on the pencil below your post - remove the image and just copy paste the compiler’s error message within code tags)

Thx for helping us maintain a nice forum

Your topic has been moved. Please do not post in "Uncategorized"; see the sticky topics in https://forum.arduino.cc/c/using-arduino/uncategorized/184.