Error Compiling Adafruit HUZZAH ESP8266 with DHT11 sensor

Hey all,

I know there are a few other topics similar to this one, but none answered my question. I am working with an Adafruit HUZZAH ESP8266 and making a temperature and humidity sensor with a DHT11 (3 pins, its on a PCB with a pull up resistor), and trying to upload the data to ThingSpeak. My setup has the DHT11 pin 1 connected to the ESP pin #5, pin 2 to ESP V+, and pin 3 to GND. I have followed the procedure here to download the DHT11 library, and here to set up ThingSpeak. I also set up the ESP8266 board driver. I got the compilation error that the DHT.h file was not found, even though I placed it in the correct folder. After some googling, I found that many people had this problem, as the version 1.3.0 DHT library apparently doesn’t work with ESP8266 (see here if you want details). I then tried downloading the older version 1.2.3 here, an got the same error message, “DHT.h: No such file or directory”.

So I then downloaded the Adafruit unified sensor driver, as recommended, and added the #include <Adafruit_Sensor.h> to my code. Still didn’t compile. Here was (and is) my full error message:

C:\Users\hayleywalker\Documents\Arduino\Libraries\cWL_10L_sensor_thingspeak_\cWL_10L_sensor_thingspeak_.ino:1:29: fatal error: Adafruit_Sensor.h: No such file or directory

 #include <Adafruit_Sensor.h>

                             ^

compilation terminated.

exit status 1
Error compiling for board Adafruit HUZZAH ESP8266.

I put all libraries in the Arduino\libraries folder as directed. I’m not sure what else to do (I also tried replacing the ESP, and checking connections).

Here is my full IDE code:

#include <Adafruit_Sensor.h>
#include <DHT.h>
 #include <ESP8266WiFi.h>  
 #include <WiFiClient.h>  
 #include <ThingSpeak.h>  
 #define DHTPIN D5  //use pin 5
 #define DHTTYPE DHT11  
 DHT dht(DHTPIN, DHTTYPE);  
 const char* ssid = "**********";  
 const char* password = "*********";  
 WiFiClient client;  
 unsigned long myChannelNumber = **********;  
 const char * myWriteAPIKey = "********";  
 uint8_t temperature, humidity;  
 void setup()  
 {  
  Serial.begin(115200);  
  dht.begin();  
  delay(10);  
  // Connect to WiFi network  
  Serial.println();  
  Serial.println();  
  Serial.print("Connecting to ");  
  Serial.println(ssid);  
  WiFi.begin(ssid, password);  
  while (WiFi.status() != WL_CONNECTED)  
  {  
   delay(500);  
   Serial.print(".");  
  }  
  Serial.println("");  
  Serial.println("WiFi connected");  
  // Print the IP address  
  Serial.println(WiFi.localIP());  
  ThingSpeak.begin(client);  
 }  
 void loop()   
 {  
  static boolean data_state = false;  
  temperature = dht.readTemperature();  
  humidity = dht.readHumidity();  
  Serial.print("Temperature Value is :");  
  Serial.print(temperature);  
  Serial.println("C");  
  Serial.print("Humidity Value is :");  
  Serial.print(humidity);  
  Serial.println("%");  
  // Write to ThingSpeak. There are up to 8 fields in a channel, allowing you to store up to 8 different  
  // pieces of information in a channel. Here, we write to field 1.  
  if( data_state )  
  {  
   ThingSpeak.writeField(myChannelNumber, 1, temperature, myWriteAPIKey);  
   data_state = false;  
  }  
  else  
  {  
   ThingSpeak.writeField(myChannelNumber, 2, humidity, myWriteAPIKey);  
   data_state = true;  
  }  
  delay(30000); // ThingSpeak will only accept updates every 15 seconds.  
 }

Any help is really appreciated. Thanks!

hayleyjw:
I have followed the procedure here to download the DHT11 library

There’s more to it than just downloading. You also need to install it.

Note that the installation instructions on that page are terrible advice. You should NEVER install anything to the Arduino IDE installation folder because it will all be lost when you upgrade to a new version of the IDE. The correct place to install libraries is to {sketchbook folder}\libraries. You can find the location of your sketchbook folder at File > Preferences > Sketchbook location. In your case the sketchbook folder is C:\Users\hayleywalker\Documents\Arduino. Libraries installed to the libraries subfolder of the sketchbook folder will persist through IDE updates. The fact that the author of that tutorial doesn’t understand this extremely basic concept tells me they don’t know what they’re talking about and all information on that site should be treated with extreme skepticism if not completely disregarded.

That said, although quite inadvisable for the reason provided above, installing the library to the libraries subfolder of the Arduino IDE installation folder will work as long as you are using the version of the Arduino IDE installed at that location so it should not have caused the “the DHT.h file was not found” error if you had followed the directions correctly.

hayleyjw:
I got the compilation error that the DHT.h file was not found, even though I placed it in the correct folder.

I really doubt that was the exact wording of the error. Paraphrasing fragments of errors is not helpful. We need to to post the full error message every time.

hayleyjw:
I got the compilation error that the DHT.h file was not found, even though I placed it in the correct folder. After some googling, I found that many people had this problem, as the version 1.3.0 DHT library apparently doesn’t work with ESP8266 (see here if you want details).

Wrong. None of those results say anything about the “the DHT.h file was not found” error.

hayleyjw:
Still didn’t compile. Here was (and is) my full error message:

C:\Users\hayleywalker\Documents\Arduino\Libraries\cWL_10L_sensor_thingspeak_\cWL_10L_sensor_thingspeak_.ino:1:29: fatal error: Adafruit_Sensor.h: No such file or directory

#include <Adafruit_Sensor.h>




I put all libraries in the Arduino\libraries folder as directed. I'm not sure what else to do

If you had installed either library correctly you wouldn’t get these errors. Please follow these easy library installation instructions:

DHT library:

Adafruit_Sensor library:

After doing that those errors should be fixed.

Hi pert,

Thanks for your help! I followed the instructions and fixed the error message. I didn't paste in the previous error message because I wasn't getting it anymore and unfortunately didn't remember the exact phrasing. Your advise worked though, however I am still having difficulties connecting to wifi. The Wifi I'm connecting to is usually very reliable, but I'm getting endless dots on the serial monitor, sometimes accompanied by this before it:

tail 8
chksum 0x2d
csum 0x2d
v09f0c112
~ld

.

I'm not sure what this message means. When compiling/running this is the last part of the IDE message:

Using library Adafruit_Sensor-1.0.2 at version 1.0.2 in folder: C:\Users\hayleywalker\Documents\Arduino\libraries\libraries\Adafruit_Sensor-1.0.2 
Using library DHT-sensor-library-1.2.3 at version 1.2.3 in folder: C:\Users\hayleywalker\Documents\Arduino\libraries\libraries\DHT-sensor-library-1.2.3 
Using library ESP8266WiFi at version 1.0 in folder: C:\Users\hayleywalker\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\ESP8266WiFi 
Using library thingspeak-arduino-master at version 1.3.0 in folder: C:\Users\hayleywalker\Documents\Arduino\libraries\libraries\thingspeak-arduino-master 
Sketch uses 234093 bytes (22%) of program storage space. Maximum is 1044464 bytes.
Global variables use 32596 bytes (39%) of dynamic memory, leaving 49324 bytes for local variables. Maximum is 81920 bytes.
Uploading 238240 bytes from C:\Users\HAYLEY~1\AppData\Local\Temp\arduino_build_212484/cWL_10L_sensor_thingspeak_.ino.bin to flash at 0x00000000
............................................................................... [ 34% ]
................................................................................ [ 68% ]
.........................................................................        [ 100% ]

. Thanks again for your tips :)