Error compiling for board Arduino Uno DHT11

I am trying to use my DHT11 Humidity and temperature sensor and as I am trying to compile and upload the program to my arduino uno it gives me the followoing error:
"Error compiling for board Arduino Uno."

#include <DHT.h>
#include <DHT_U.h>

#define dht_apin A0
dht DHT;
void setup() {
  // put your setup code here, to run once:
Serial.println ("DHT11 Humidity & Temperature Sensone\n\n");

void loop() {
  // put your main code here, to run repeatedly:
Serial.print ("humidity = ")
Serial.print ("temperature = ");
Serial.print (DHT.temperature);
Serial.println ("C");
delay (1000);

Hi @amito55. I'm going to ask you to post some additional information that might help us to identify the problem.

Please do this:

  1. If you don't still have the IDE or web editor open with the error present, repeat the process that generated it.
  2. You now need to copy the full and exact text of the output. The procedure for doing this is different depending on which Arduino development software you are using:
    • Arduino IDE 1.x: Click the Copy error messages button on the right side of the orange bar in the IDE.
    • Arduino IDE 2.x: Right click on the black "Output" pane at the bottom of the IDE window and then select Copy All from the context menu.
    • Arduino Web Editor: Click the icon that looks like two pieces of paper at the top right corner of the black console window Web Editor.
  3. Open a forum reply here by clicking the Reply button.
  4. Click the </> icon on the post composer toolbar. This will add the forum's code block markup (```) to your reply to make sure the error messages are correctly formatted.
    Code block
  5. Press Ctrl+V. This will paste the compilation output into the code block.
  6. Move the cursor outside of the code block markup before you add any additional text to your reply.
  7. Click the Reply button to post the output.

Hey, thanks for fast response!
the error message is this:

Arduino: 1.8.15 (Windows 8.1), Board: "Arduino Uno"

In file included from C:\Users\Amit\AppData\Local\Temp\arduino_modified_sketch_554028\BareMinimum.ino:2:0:

C:\Users\Amit\Documents\Arduino\libraries\DHT_sensor_library-1.4.2/DHT_U.h:36:10: fatal error: Adafruit_Sensor.h: No such file or directory

 #include <Adafruit_Sensor.h>


compilation terminated.

exit status 1

Error compiling for board Arduino Uno.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Did you install that correctly?

I'm not sure, how do i check that?

With the IDE's library manager.

The compiler thinks you didn't

Check the library manager to see if you have it installed:

3rd box down.

i dont see it in my libraries, i have only adafruit circuit playground

I have downloaded and installed the adfruit library which includes the DHT11 sensor in it
yet I get the same error message.

Do this:

  1. Select Sketch > Include Library > Manage Libraries... from the Arduino IDE's menus.

  2. Wait for the update to finish.

  3. In the "Filter your search" field, type adafruit unified sensor.

  4. Press Enter.

  5. Scroll down through the list of libraries until you see "Adafruit Unified Sensor by Adafruit". Click on it.

  6. Click the Install button.

  7. You may now get a dialog asking:

    Would you like to install also all the missing dependencies?

    If so, click the Install all button.

  8. Wait for the installation to finish.

  9. Click the Close button.

Now try compiling your sketch again.

amazing! Thanks!
but now a new error came up. :frowning:

Arduino: 1.8.15 (Windows 8.1), Board: "Arduino Uno"

BareMinimum:7:1: error: 'dht' does not name a type

 dht DHT;


C:\Users\Amit\AppData\Local\Temp\arduino_modified_sketch_955262\BareMinimum.ino: In function 'void loop()':

BareMinimum:18:4: error: expected unqualified-id before '.' token



BareMinimum:20:1: error: expected ';' before 'Serial'



BareMinimum:22:18: error: expected primary-expression before '.' token

 Serial.print (DHT.temperature);


exit status 1

'dht' does not name a type

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

You have them the wrong way round: DHT is the type, dht is the variable of that type.

That ought to be true, but I've got a nasty feeling some libraries/examples have it the wrong way around

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