Error compiling (SOLVED)

I can't figure out why it won't compile, I've tried every I know.

//include the libraries
#include <dht.h>
#include <LiquidCrystal_I2C.h>
#include <Wire.h> 
LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display

dht DHT;//create a variable type of dht

const int DHT11_PIN= 7;//Humiture sensor attach to pin7

void setup()
{
  Serial.begin(9600);//initialize the serial
  lcd.init(); //initialize the lcd
  lcd.backlight(); //open the backlight 
}

void loop()
{
  // READ DATA
  //Serial.println("DHT11:");

  int chk = DHT.read11(DHT11_PIN);//read the value returned from sensor
  switch (chk)
  {
    case DHTLIB_OK: 
    //Serial.println("OK!"); 
    break;
    case DHTLIB_ERROR_CHECKSUM: 
    //Serial.print("Checksum error,\t"); 
    break;
    case DHTLIB_ERROR_TIMEOUT: 
    //Serial.print("Time out error,\t"); 
    break;
    default: 
    //Serial.print("Unknown error,\t"); 
    break;
  }
  // DISPLAY DATA
  lcd.setCursor(0, 0);
  lcd.print("Tem:");
  //Serial.print("Tem:");
  lcd.print(DHT.temperature,1); //print the temperature on lcd
  // Serial.print(DHT.temperature,1);
  lcd.print(char(223));//print the unit" ℃ "
  lcd.print("C");
  // Serial.println(" C");
  lcd.setCursor(0, 1);
  lcd.print("Hum:");
  //Serial.print("Hum:");
  lcd.print(DHT.humidity,1); //print the humidity on lcd
  //Serial.print(DHT.humidity,1);
  lcd.print(" %"); 
  //Serial.println(" %");
  delay(200); //wait a while 
}

error (exit status 1
Error compiling for board Arduino/Genuino Uno.)

Thanks!

Post the complete error message. It should identify the line number where it found the error.

...R

Do you have the dht library installed properly?

Review these:

error (exit status 1
Error compiling for board Arduino/Genuino Uno.)

Is that the complete error message ?

That is the end of error, what is caused it is described before that, all orange lines.

Please post all the error message

ted:
That is the end of error, what is caused it is described before that, all orange lines.

Has it not crossed your mind that that will be useful information for people trying to help you?

...R

WOW! I didn't expect such a quick response! You guys were right libraries are my problem, here's some progress I've made (I think)

//include the libraries
#include <DHT.h>
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
LiquidCrystal lcd(0x27, 16, 2); // set the LCD address to 0x27 for a 16 chars and 2 line display

dht DHT;//create a variable type of dht

const int DHT11_PIN = 7; //Humiture sensor attach to pin7

void setup()
{
  Serial.begin(9600);//initialize the serial monitor
  lcd.init();  //initialize the lcd
  lcd.backlight();  //open the backlight
}

void loop()
{
  // READ DATA
  //Serial.println("DHT11:");

  int chk = DHT.read11(DHT11_PIN);//read the value returned from sensor
  switch (chk)
  {
    case DHTLIB_OK:
      //Serial.println("OK!");
      break;
    case DHTLIB_ERROR_CHECKSUM:
      //Serial.print("Checksum error,\t");
      break;
    case DHTLIB_ERROR_TIMEOUT:
      //Serial.print("Time out error,\t");
      break;
    default:
      //Serial.print("Unknown error,\t");
      break;
  }
  // DISPLAY DATA
  lcd.setCursor(0, 0);
  lcd.print("Tem:");
  //Serial.print("Tem:");
  lcd.print(DHT.temperature, 1); //print the temperature on lcd
  // Serial.print(DHT.temperature,1);
  lcd.print(char(223));//print the unit" ℃ "
  lcd.print("C");
  // Serial.println(" C");
  lcd.setCursor(0, 1);
  lcd.print("Hum:");
  //Serial.print("Hum:");
  lcd.print(DHT.humidity, 1); //print the humidity on lcd
  //Serial.print(DHT.humidity,1);
  lcd.print(" %");
  //Serial.println(" %");
  delay(200); //wait a while
}

(errors)
Arduino: 1.8.5 (Windows Store 1.8.10.0) (Windows 10), Board: "Arduino/Genuino Uno"

In file included from C:\Users\alkre\OneDrive\Documents\Arduino\libraries\DHT-sensor-library-master\DHT_U.cpp:22:0:

C:\Users\alkre\OneDrive\Documents\Arduino\libraries\DHT-sensor-library-master\DHT_U.h:25:29: fatal error: Adafruit_Sensor.h: No such file or directory

#include <Adafruit_Sensor.h>

^

compilation terminated.

Multiple libraries were found for "LiquidCrystal_I2C.h"
Used: C:\Users\alkre\OneDrive\Documents\Arduino\libraries\LiquidCrystal_I2C
Not used: C:\Users\alkre\OneDrive\Documents\Arduino\libraries\Arduino-LiquidCrystal-I2C-library-master
exit status 1
Error compiling for board Arduino/Genuino Uno.

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

Thanks a lot guys!

You also need the Adafruit_Sensor library.

You need to install and include a library called Adafruit Unified Sensor. v1.0.2 is available through the library manager.

IMPORTANT: As of version 1.3.0 of the DHT library you will also need to install the Adafruit_Sensor library, which is available from the Arduino library manager:

Ok I did that here's my new errors: (the code is the same)

Arduino: 1.8.5 (Windows Store 1.8.10.0) (Windows 10), Board: "Arduino/Genuino Uno"

sketch_dec26a:13: error: 'LiquidCrystal' does not name a type

LiquidCrystal lcd(0x27, 16, 2); // set the LCD address to 0x27 for a 16 chars and 2 line display

^

sketch_dec26a:15: error: 'dht' does not name a type

dht DHT;//create a variable type of dht

^

C:\Users\alkre\OneDrive\Documents\Arduino\sketch_dec26a\sketch_dec26a.ino: In function 'void setup()':

sketch_dec26a:22: error: 'lcd' was not declared in this scope

lcd.init(); //initialize the lcd

^

C:\Users\alkre\OneDrive\Documents\Arduino\sketch_dec26a\sketch_dec26a.ino: In function 'void loop()':

sketch_dec26a:31: error: expected primary-expression before '.' token

int chk = DHT.read11(DHT11_PIN);//read the value returned from sensor

^

sketch_dec26a:34: error: 'DHTLIB_OK' was not declared in this scope

case DHTLIB_OK:

^

sketch_dec26a:37: error: 'DHTLIB_ERROR_CHECKSUM' was not declared in this scope

case DHTLIB_ERROR_CHECKSUM:

^

sketch_dec26a:40: error: 'DHTLIB_ERROR_TIMEOUT' was not declared in this scope

case DHTLIB_ERROR_TIMEOUT:

^

sketch_dec26a:48: error: 'lcd' was not declared in this scope

lcd.setCursor(0, 0);

^

sketch_dec26a:51: error: expected primary-expression before '.' token

lcd.print(DHT.temperature, 1); //print the temperature on lcd

^

sketch_dec26a:59: error: expected primary-expression before '.' token

lcd.print(DHT.humidity, 1); //print the humidity on lcd

^

Multiple libraries were found for "LiquidCrystal_I2C.h"
Used: C:\Users\alkre\OneDrive\Documents\Arduino\libraries\LiquidCrystal_I2C
Not used: C:\Users\alkre\OneDrive\Documents\Arduino\libraries\Arduino-LiquidCrystal-I2C-library-master
exit status 1
'LiquidCrystal' does not name a type

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

There is this obvious syntax error on the constructor for the lcd display

//LiquidCrystal lcd(0x27, 16, 2); // set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C  lcd(0x27, 16, 2);

I'm not sure where the DHT code came from, but the syntax does not match what I see in the Adafruit libraries. There are two example sketchs- DHT_Unified_Sensor and DHTtester which you should take a look at.

Ok I looked up DHT in my files and about 40 files came up, so should I delete some of them?

Ok I looked up DHT in my files and about 40 files came up, so should I delete some of them?

I have no idea of what you are dealing with, but typically I always run the library examples when working with a new piece of hardware.

It is also worthwhile to actually look at the library files, to understand the syntax and functions available and see additional information to what is in the examples.

Ok I fixed the dht library but I still have these errors:

Arduino: 1.8.5 (Windows Store 1.8.10.0) (Windows 10), Board: "Arduino/Genuino Uno"

sketch_dec26a:13: error: 'LiquidCrystal' does not name a type

LiquidCrystal lcd(0x27, 16, 2); // set the LCD address to 0x27 for a 16 chars and 2 line display

^

sketch_dec26a:15: error: 'dht' does not name a type

dht DHT;//create a variable type of dht

^

C:\Users\alkre\OneDrive\Documents\Arduino\sketch_dec26a\sketch_dec26a.ino: In function 'void setup()':

sketch_dec26a:22: error: 'lcd' was not declared in this scope

lcd.init(); //initialize the lcd

^

C:\Users\alkre\OneDrive\Documents\Arduino\sketch_dec26a\sketch_dec26a.ino: In function 'void loop()':

sketch_dec26a:31: error: expected primary-expression before '.' token

int chk = DHT.read11(DHT11_PIN);//read the value returned from sensor

^

sketch_dec26a:34: error: 'DHTLIB_OK' was not declared in this scope

case DHTLIB_OK:

^

sketch_dec26a:37: error: 'DHTLIB_ERROR_CHECKSUM' was not declared in this scope

case DHTLIB_ERROR_CHECKSUM:

^

sketch_dec26a:40: error: 'DHTLIB_ERROR_TIMEOUT' was not declared in this scope

case DHTLIB_ERROR_TIMEOUT:

^

sketch_dec26a:48: error: 'lcd' was not declared in this scope

lcd.setCursor(0, 0);

^

sketch_dec26a:51: error: expected primary-expression before '.' token

lcd.print(DHT.temperature, 1); //print the temperature on lcd

^

sketch_dec26a:59: error: expected primary-expression before '.' token

lcd.print(DHT.humidity, 1); //print the humidity on lcd

^

exit status 1
'LiquidCrystal' does not name a type

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

Please re read post #11 for an obvious error with the lcd constructor.

Can you compile and run the library examples for the DHT sensor?

I'm sorry I didn't realize there was a second page :sob: . I made LiquidCrystal into LiquidCrystal_I2c, and yes the dht.test does work (verify and upload). New code:

//include the libraries
#include <DHT.h>
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
LiquidCrystal_I2c lcd(0x27, 16, 2); // set the LCD address to 0x27 for a 16 chars and 2 line display

dht DHT;//create a variable type of dht

const int DHT11_PIN = 7; //Humiture sensor attach to pin7

void setup()
{
  Serial.begin(9600);//initialize the serial monitor
  lcd.init();  //initialize the lcd
  lcd.backlight();  //open the backlight
}

void loop()
{
  // READ DATA
  //Serial.println("DHT11:");

  int chk = DHT.read11(DHT11_PIN);//read the value returned from sensor
  switch (chk)
  {
    case DHTLIB_OK:
      //Serial.println("OK!");
      break;
    case DHTLIB_ERROR_CHECKSUM:
      //Serial.print("Checksum error,\t");
      break;
    case DHTLIB_ERROR_TIMEOUT:
      //Serial.print("Time out error,\t");
      break;
    default:
      //Serial.print("Unknown error,\t");
      break;
  }
  // DISPLAY DATA
  lcd.setCursor(0, 0);
  lcd.print("Tem:");
  //Serial.print("Tem:");
  lcd.print(DHT.temperature, 1); //print the temperature on lcd
  // Serial.print(DHT.temperature,1);
  lcd.print(char(223));//print the unit" ℃ "
  lcd.print("C");
  // Serial.println(" C");
  lcd.setCursor(0, 1);
  lcd.print("Hum:");
  //Serial.print("Hum:");
  lcd.print(DHT.humidity, 1); //print the humidity on lcd
  //Serial.print(DHT.humidity,1);
  lcd.print(" %");
  //Serial.println(" %");
  delay(200); //wait a while
}

errors:

Arduino: 1.8.5 (Windows Store 1.8.10.0) (Windows 10), Board: "Arduino/Genuino Uno"

sketch_dec26a:13: error: 'LiquidCrystal_I2c' does not name a type

LiquidCrystal_I2c lcd(0x27, 16, 2); // set the LCD address to 0x27 for a 16 chars and 2 line display

^

sketch_dec26a:15: error: 'dht' does not name a type

dht DHT;//create a variable type of dht

^

C:\Users\alkre\OneDrive\Documents\Arduino\sketch_dec26a\sketch_dec26a.ino: In function 'void setup()':

sketch_dec26a:22: error: 'lcd' was not declared in this scope

lcd.init(); //initialize the lcd

^

C:\Users\alkre\OneDrive\Documents\Arduino\sketch_dec26a\sketch_dec26a.ino: In function 'void loop()':

sketch_dec26a:31: error: expected primary-expression before '.' token

int chk = DHT.read11(DHT11_PIN);//read the value returned from sensor

^

sketch_dec26a:34: error: 'DHTLIB_OK' was not declared in this scope

case DHTLIB_OK:

^

sketch_dec26a:37: error: 'DHTLIB_ERROR_CHECKSUM' was not declared in this scope

case DHTLIB_ERROR_CHECKSUM:

^

sketch_dec26a:40: error: 'DHTLIB_ERROR_TIMEOUT' was not declared in this scope

case DHTLIB_ERROR_TIMEOUT:

^

sketch_dec26a:48: error: 'lcd' was not declared in this scope

lcd.setCursor(0, 0);

^

sketch_dec26a:51: error: expected primary-expression before '.' token

lcd.print(DHT.temperature, 1); //print the temperature on lcd

^

sketch_dec26a:59: error: expected primary-expression before '.' token

lcd.print(DHT.humidity, 1); //print the humidity on lcd

^

exit status 1
'LiquidCrystal_I2c' does not name a type

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

Let's address the dht problem first. The very first error reported was and we focused on the missing adafruit sensor library.

In file included from C:\Users\alkre\OneDrive\Documents\Arduino\libraries\DHT-sensor-library-master\DHT_U.cpp:22:0:

C:\Users\alkre\OneDrive\Documents\Arduino\libraries\DHT-sensor-library-master\DHT_U.h:25:29: fatal error: Adafruit_Sensor.h: No such file or directory

 #include <Adafruit_Sensor.h>

There are several libraries called DHT. One is the adafruit libary which capitalizes the DHT. in the DHT.cpp and DHT.h files

Then there is this one from Rob Tillart which uses an uncapitlaized dht.cpp and dht.h

You are trying to use the dht11_test.ino example file from the Tillart library with the Adafruit library. These two libraries are very different, and use different syntax and you can not just cross use examples and libraries.

Regarding the LiquidCrystal_I2c error, try

LiquidCrystal_I2C lcd(0x27, 16, 2); // set the LCD address to 0x27 for a 16 chars and 2 line display

//LiquidCrystal_I2c lcd(0x27, 16, 2); // set the LCD address to 0x27 for a 16 chars and 2 line display

Capitalization is important, and the library is called

#include <LiquidCrystal_I2C.h>

Do you know that this library will work with your lcd display. There are several different i2c display configurations and this library will only work with some of them. Have you run the library example and confirmed that your display works correctly with this library. If not, there is a surefire way to go using a self configuring library called hd44780.

It's fixed!! It was mostly in the library's, it uploads and works just like should. It reads in celsius, is there a easy way to use fahrenheit? Thank you for all the help, it means a lot to me! :slight_smile:

s there a easy way to use fahrenheit?

I assume that you know how to convert between the two ?