Compilation error Arduino

Compilation error Arduino
I have created a simple sketch using a DHT11 sensor.

#include <DHTesp.h>

#include"DHT.h"
#define DHTP 2
#define DF DHT11
DHT dht(DHTP,DF);
void setup(){
  
  dht.begin();
  Serial.begin(9600);
  
  

}
void loop(){
  int data=dht.read11(DHTP);
  float t= dht.readTemperature;
  float y= dht.readHumidity;
  Serial.println(t);
  Serial.println(y);
}



I keep getting the error message

 Arduino: 1.8.20 Hourly Build 2021/12/20 07:33 (Windows 10), Board: "Arduino Uno"
In file included from C:\Users\FILE\Documents\Arduino\libraries\DHT_sensor_library\DHT_U.cpp:15:0C:\Users\FILE\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.

Welcome to the forum

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the </> icon above the compose window) to make it easier to read and copy for examination

Hi @omnamavana. I'm going to ask you to post some additional information that might help us to identify the problem.

Please do this:

  1. If you don't still have the IDE or web editor open with the error present, repeat the process that generated it.
  2. You now need to copy the full and exact text of the output.
    The procedure for doing this is different depending on which Arduino development software you are using:
    • Arduino IDE 1.x: Click the Copy error messages button on the right side of the orange bar in the IDE.
    • Arduino IDE 2.x: Right click on the black "Output" panel at the bottom of the IDE window and then select "Copy All" from the context menu.
    • Arduino Web Editor: Click the icon that looks like two pieces of paper at the top right corner of the black console window Web Editor.
  3. Open a forum reply here by clicking the Reply button.
  4. Click the </> icon on the post composer toolbar.
    This will add the forum's code block markup (```) to your reply to make sure the error messages are correctly formatted.
    Code block
  5. Press Ctrl+V.
    This will paste the compilation output into the code block.
  6. Move the cursor outside of the code block markup before you add any additional text to your reply.
  7. Click the Reply button to post the output.

Hi @in0,
I have editted the post as per your instruction let me know if this is sufficient to answer the question. :slightly_smiling_face:

You have not posted the full error message but I suspect that the error you are getting is related to

  'class DHT' has no member named 'read11'; did you mean 'read'?

Where did you get the code and which Arduino are you using as you seem to be trying to use two DHT libraries

Hi @UKHeliBob I am using the arduino uno board.I am using the liabrary Adafruit/DHT-sensor-liabrary,Arduino library for DHT11, DHT22, etc Temperature & Humidity Sensors
according to one of the previous replies,I have clicked on copy error message and pasted it as it is here .
I have tried using the simpleDHT liabrary as well and the same occurs

This tells you that you haven't installed the Adafruit_Sensor library.

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