Go Down

Topic: Compile Fatal Error: Adafruit_Sensor.h: No such file (Read 23774 times) previous topic - next topic

johnowenschina

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.




Code: [Select]
// 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

But I cannot find this in the Library Manager.

Thanks in advanced.
John

ballscrewbob

#1
Apr 17, 2017, 02:57 am Last Edit: Apr 17, 2017, 02:59 am by Ballscrewbob
It is there I can assure you.

There are three boxes at the top of the library manager



All I did was type unified into the third box and scroll down.

Its a lib I also use so I am surprised you did not see it.

It may not be the answer you were looking for but its the one I am giving based on either experience, educated guess, google or the fact that you gave nothing to go with in the first place so I used my wonky crystal ball.

johnowenschina

Thanks. Found it using "Unified". I searched "Adafruit Sensor" before.

YasithSilva

Thanks ballscrewbob  . well your solution was the perfect for my project

crmmvio

Thanks ballscrewbob. your tip help me very much

SquigyXIII

BallScrewBob's fix didn't work for me.  When I search for "unified" in the library manager there are no results.

any other suggesstions?

ballscrewbob

@SquigyXIII

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.


It may not be the answer you were looking for but its the one I am giving based on either experience, educated guess, google or the fact that you gave nothing to go with in the first place so I used my wonky crystal ball.

Go Up