Hi all.
This is my first attempt to write a simple sketch, i am trying to test a DHT22 Temp & Humidity sensor showing the results on the Serial Monitor. I have successfully downloaded a DHT22 zip.file into the IDE libraries, i have used the sketch below, but i keep getting the error messages below, i hope i have upload the sketch correctly, if i have not please forgive me, there 's an awful lot of learning going on.
Regards
Ray
/* How to use the DHT-22 sensor with Arduino uno
Temperature and humidity sensor
*/
//Libraries
#include <DHT.h>;
//Constants
#define DHTPIN 2 // what pin we're connected to
#define DHTTYPE DHT22 // DHT 22
DHT dht(DHTPIN, DHTTYPE); //// Initialize DHT sensor for normal 16mhz Arduino
//Variables
int chk;
float hum; //Stores humidity value
float temp; //Stores temperature value
void setup()
{
Serial.begin(9600);
dht.begin();
}
void loop()
{
delay(2000);
//Read data and store it to variables hum and temp
hum = dht.readHumidity();
temp= dht.readTemperature();
//Print temp and humidity values to serial monitor
Serial.print("Humidity: ");
Serial.print(hum);
Serial.print(" %, Temp: ");
Serial.print(temp);
Serial.println(" Celsius");
delay(10000); //Delay 2 sec.
}
Arduino: 1.8.5 (Windows 7), Board: "Arduino/Genuino Uno"
In file included from C:\Users\dell\Documents\Arduino\libraries\DHT_sensor_library-1.3.0\DHT_U.cpp:22:0:
C:\Users\dell\Documents\Arduino\libraries\DHT_sensor_library-1.3.0\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 Uno.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
sketch_dec04a.ino (2.02 KB)