My First attempt at Sketch Writing

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)

Another first?

You missed a bit on the library site (which is always good to include in a post):

You must have the following Arduino libraries installed to use this class:

Adafruit Unified Sensor Library

:wink:

AWOL,

Sarcasm will get you nowhere.

You say "sarcasm", I say " confusion".

Let's call the whole thing off.

AWOL.

You are dead right, i was confused, that's why i asked the Forum for help, after all i am learning.

Incidentally, it is still my first sketch, albeit very modified.

Ray

Are you still getting the error message? Did you try following reply #2?

Septilion.

Many thanks, i downloaded the Adafruit sensor zip. and the sketch worked first time, Problem now is Humidity only reads 1% on the Serial Monitor?

Regards

Ray

gresleyman:
Septilion.

Many thanks, i downloaded the Adafruit sensor zip. and the sketch worked first time, Problem now is Humidity only reads 1% on the Serial Monitor?

Regards

Ray

Breathe on it.

I have breathed on it, temperature goes up, humidity stays at 1%

Regards

Ray

gresleyman:
I have breathed on it, temperature goes up, humidity stays at 1%

Regards

Ray

It might be defective. I had the same problem with a DHT22, even stored it in a jar with water overnight to reset it, as suggested somewhere. It never reads over 10%. I vastly prefer the SI7021.