Nano ATMega168 Compilation error

Hi to all
I have an Arduino Nano ATMega168 and i am trying to upload any scetsh.
Every time i try to upload something i get the error
“Error compiling for board Arduino Nano.”
I try to upload a simple sketch for DHT11 sensor.
Here is the code:

#include <dht.h>
#define dataPin 8 // Defines pin number to which the sensor is connected
dht DHT; // Creats a DHT object
void setup() {
  Serial.begin(9600);
}
void loop() {
  int readData = DHT.read22(dataPin); // Reads the data from the sensor
  float t = DHT.temperature; // Gets the values of the temperature
  float h = DHT.humidity; // Gets the values of the humidity
  
  // Printing the results on the serial monitor
  Serial.print("Temperature = ");
  Serial.print(t);
  Serial.print(" *C ");
  Serial.print("    Humidity = ");
  Serial.print(h);
  Serial.println(" % ");
  
  delay(2000); // Delays 2 secods, as the DHT22 sampling rate is 0.5Hz
}

I am new to arduino and it is the first time i use Nano.

"Error compiling for board Arduino Nano."

It says more than that.

How is this an "Installation and troubleshooting" question?

Do you have the library dht.h installed?

Which version IDE ?

If its a newer one are you selecting the correct FLAVOUR of board ?

CrossRoads:
Do you have the library dht.h installed?

Yes i have this library.
With Arduino UNO R3 the sketch has no problem.

When you encounter an error you’ll see a button on the right side of the orange bar “Copy error messages”. Click that button. Paste the error in a message here USING CODE TAGS (</> button on the toolbar).

ballscrewbob:
Which version IDE ?

If its a newer one are you selecting the correct FLAVOUR of board ?

I have the latest IDE installed.Version 1.8.5
I have choose the Nano Arduino and in processor ATMega168

jxid:
I have the latest IDE installed.Version 1.8.5

1.8.7 is the latest IDE version. Your 1.8.5 is a year out of date.

pert:
1.8.7 is the latest IDE version. Your 1.8.5 is a year out of date.

I am trying know the latest version.

Try the project with the latest Arduino IDE version 1.8.7
I made some changes in the code

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

//#include <dht.h>
#define DHTPIN 8 // Defines pin number to which the sensor is connected
#define DHTTYPE DHT11   // DHT 11
DHT dht(DHTPIN, DHTTYPE); // Creats a DHT object
void setup() {
  Serial.begin(9600);
}
void loop() {
//  int readData = dht.read22(DHTPIN); // Reads the data from the sensor
  float t = DHT.temperature; // Gets the values of the temperature
  float h = DHT.humidity; // Gets the values of the humidity
  
  // Printing the results on the serial monitor
  Serial.print("Temperature = ");
  Serial.print(t);
  Serial.print(" *C ");
  Serial.print("    Humidity = ");
  Serial.print(h);
  Serial.println(" % ");
  
  delay(2000); // Delays 2 secods, as the DHT22 sampling rate is 0.5Hz
}

When veryfing projet i get again errors.
Here is the “Copy massage” Button contents:

Arduino: 1.8.7 (Windows 10), Board: "Arduino Nano, ATmega168"

C:\Users\Yannis\Documents\Arduino\DHT11_Serial_Monitor_Nano_ATMega168\DHT11_Serial_Monitor_Nano_ATMega168.ino: In function 'void loop()':

DHT11_Serial_Monitor_Nano_ATMega168:13:16: error: expected primary-expression before '.' token

   float t = DHT.temperature; // Gets the values of the temperature

                ^

DHT11_Serial_Monitor_Nano_ATMega168:14:16: error: expected primary-expression before '.' token

   float h = DHT.humidity; // Gets the values of the humidity

                ^

Multiple libraries were found for "DHT.h"
 Used: C:\Users\Yannis\Documents\Arduino\libraries\DHTsensorlibrarymaster
 Not used: C:\Users\Yannis\Documents\Arduino\libraries\DHT-sensor-library-master
exit status 1
expected primary-expression before '.' token

Invalid library found in C:\Users\Yannis\Documents\Arduino\libraries\HMC5883L_Simple-master: no headers files (.h) found in C:\Users\Yannis\Documents\Arduino\libraries\HMC5883L_Simple-master
Invalid library found in C:\Users\Yannis\Documents\Arduino\libraries\u8glib-master: no headers files (.h) found in C:\Users\Yannis\Documents\Arduino\libraries\u8glib-master

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

DHT dht(DHTPIN, DHTTYPE); DHT is the case, dht is the object.

I tried the sketch below and everything is OK
But still i can not understand what is wrong with the sketch in my first post.

#include "dht.h"
#define dht_apin A0 // Analog Pin sensor is connected to
 
dht DHT;
 
void setup(){
 
  Serial.begin(9600);
  delay(500);//Delay to let system boot
  Serial.println("DHT11 Humidity & temperature Sensor\n\n");
  delay(1000);//Wait before accessing Sensor
 
}//end "setup()"
 
void loop(){
  //Start of Program 
 
    DHT.read11(dht_apin);
    
    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 sensor again.

 
}