I am trying to compile the following code on a MKR1000, but I keep getting an error message: Arduino: 1.8.2 (Windows 10), Board: "Arduino/Genuino MKR1000" In file included from C:\Users\johno\Documents\Arduino\libraries\DHT_sensor_library\DHT_U.cpp:22:0: C:\Users\johno\Documents\Arduino\libraries\DHT_sensor_library\DHT_U.h:25:29: fatal error: Adafruit_Sensor.h: No such file or directory #include <Adafruit_Sensor.h> compilation terminated. exit status 1 Error compiling for board Arduino/Genuino MKR1000.
// Libraries
#include "DHT.h"
// Pins
int sensorPin = A0;
#define DHTPIN 5
#define DHTTYPE DHT22
// Initialize DHT sensor
DHT dht(DHTPIN, DHTTYPE, 15);
void setup() {
// Serial
Serial.begin(115200);
// Init DHT
dht.begin();
}
void loop() {
// Reading temperature and humidity
float humidity = dht.readHumidity();
// Read temperature as Celsius
float temperature = dht.readTemperature();
// Display
Serial.print("Temperature: ");
Serial.print(temperature);
Serial.println(" C");
Serial.print("Humidity: ");
Serial.print(humidity);
Serial.println(" %");
// Reading from analog sensor
int sensorValue = analogRead(sensorPin);
float lightLevel = sensorValue/1024.*100;
// Display
Serial.print("Light level: ");
Serial.print(lightLevel);
Serial.println(" %");
Serial.println();
// Wait
delay(500);
}
I have installed the DHT sensor library by Adafruit 1.3.0.
However, the Adafruit site says:
This library also includes an optional class for the DHT humidity and temperature sensor which is designed to work with the Adafruit unified sensor library.
You must have the following Arduino libraries installed to use this class:Adafruit Unified Sensor Library
There are no less than 15 unified libraries.
And just to be sure I checked again and YEP they are all still there in the regular desktop IDE.
There are 12 in CREATE editor as I checked that too.
Clearly you did something wrong or have something not setup correctly.
No to revive and old thread, but I'm having the same issue (fatal error). I did install/add the library but the issue is not resolved. Here is the Error Message I get:
LUXSensor_TSL2561_tutorial:2:10: fatal error: Adafruit_Sensor.h: No such file or directory
#include <Adafruit_Sensor.h>
^~~~~~~~~~~~~~~~~~~
compilation terminated.
exit status 1
Adafruit_Sensor.h: No such file or directory
Hello, Welcome to the Arduino Forum. This guide explains how to get the best out of this forum. Please read and follow the instructions below. Being new here you might think this is having rules for the sake of rules, but that is not the case. If you don’t follow the guidelines all that happens is there is a long exchange of posts while we try to get you to tell us what we need in order to help you, which is frustrating for you and frustrating for us. The people who try to help with your project.
It will help you get the very best out of the forum in the future.
Mention if you are using AI generated code it is important information.
Your OS and version can be valuable information, please include it along with extra security you are using. Antivirus etc.
Always list the version of the IDE you are using and the board version if applicable.
Use quote or CODE tags to add error messages as an attachment NOT a picture.
Thank you ... I did install the library (or so I thought). It turns out my anti-virus was causing the library folders to be empty. Issue resolved, I simply install libraries manually now. thank You