Error Message

I copied this code from the Arduino Project Hub and I get the following error message when I check the code before I try to download. How do I correct this issue as I get this issue when ever I copy or download code that has been written from sources such a Githup. I will post the error message and the cod will follow.

Error message:

Arduino: 1.8.13 (Windows Store 1.8.42.0) (Windows 10), Board: "Arduino Uno"

In file included from C:\Users\leave\OneDrive\Documents\Arduino\libraries\DHT_sensor_library\DHT_U.cpp:15:0:

C:\Users\leave\OneDrive\Documents\Arduino\libraries\DHT_sensor_library\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.

Code:
/*

  • Library required: -
  • "LiquidCrystal", "DHT_sensor_library" and "Adafruit_Sensor-master" -
  • Download: Adafruit_Sensor-master on Github: GitHub - adafruit/Adafruit_Sensor: Common sensor library -
  • Put it in your Arduiono dictory "libraries" -
  • License: GNU General Public License version 3 or later (GPL3+) -
  • By HilfePlus -

*/

// --Library-- / Bibliotheken
#include <LiquidCrystal.h>
#include <DHT.h>

// Sensor DHT-11 (DHT-11 Temperature and Humidity Sensor)
#define DHTPIN 8
#define DHTTYPE DHT11

// LCD Display (PIN)(LCD1602 Module)
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
DHT dht(DHTPIN, DHTTYPE);

void setup() {
// Serial Monitor
Serial.begin(9600);

// LCD Display
lcd.begin(16, 2);
lcd.setCursor(7,1);
lcd.print("By Hilfe+");
dht.begin();

// LCD Display (Temp and Humidity)
lcd.setCursor(0,0);
lcd.print("Temp:");
lcd.setCursor(0,1);
lcd.print("Humid:");
delay(1500);
}

void loop() {
lcd.setCursor(12,1);
lcd.print("%");
// Load (Arrow)
delay(550);
lcd.setCursor(13,0);
lcd.print("<");
delay(50);
lcd.setCursor(14,0);
lcd.print("-");
delay(50);
lcd.setCursor(15,0);
lcd.print("-");
delay(50);
lcd.setCursor(15,1);
lcd.print("-");
delay(50);
lcd.setCursor(14,1);
lcd.print("-");
delay(50);
lcd.setCursor(13,1);
lcd.print("<");

// ...
lcd.setCursor(12,0);
lcd.print(" ");

// -- Temp and Humidity --
// Temp = Temperature in Fahrenheit and Humid = Humidity
float f = dht.readHumidity();
float c = dht.readTemperature(true);

// Sensor Error (For Example No Sensor)
if (isnan(f) && (c)) {
lcd.clear();
lcd.setCursor(4,1);
lcd.print("|SENSOR|");
lcd.setCursor(4,0);
lcd.print("|ERROR |");
delay(1000);
return;
}

// LCD Display (values)
lcd.setCursor(7,0);
lcd.print(c);
lcd.setCursor(7,1);
lcd.print(f);

// Serial Monitor
Serial.println("- Result -");
Serial.print("Temp: ");
Serial.println(c);
Serial.print("Humid: ");
Serial.println(f);
Serial.println("- - - - - -");
Serial.println(" ");
Serial.println(" ");

// Ende (Arrow)
delay(400);
lcd.setCursor(15,1);
lcd.print(" ");
delay(50);
lcd.setCursor(14,1);
lcd.print(" ");
delay(50);
lcd.setCursor(13,1);
lcd.print(" ");
delay(50);
lcd.setCursor(13,0);
lcd.print(" ");
delay(50);
lcd.setCursor(14,0);
lcd.print(" ");
delay(50);
lcd.setCursor(15,0);
lcd.print(" ");
delay(50);
}

Install the Adafruit_Sensor library

And please edit your post and put
** **[code]** **
before your code and
** **[/code]** **
after your code so it looks like

your code here

What I don't understand is why I get the error message. I've copied or downloaded code from the Arduino site or other sites like Github before and very rarely have issues. Lately, I am getting the error message more often than not.

You're going to get this error message any time you have not installed a library dependency of the sketch you're attempting to compile. That's just how it works. Some sketches don't require any additional libraries to be installed, so you'll find you can compile those without installing libraries. The Adafruit_Sensor library is a dependency of the DHT_sensor_library your sketch uses, so it will never compile if you don't have that library installed.

If you are getting some unexpected results, you are welcome to provide details and we'll check it out, but what you've shared so far only indicates that you were trying to compile a sketch that had a dependency on the Adafruit_Sensor library when you hadn't installed that library.

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