DHT22 Temperature & Humidity sensor NEED HELP

ok so i am fairly new to sketching arduino and i tend to find sketch online and copy and paste to make a working sketch, well i cant seem to get my DHT22 to work with my exisiting sketch… i got a working libraries from (Overview | DHT11, DHT22 and AM2302 Sensors | Adafruit Learning System)

i am using a arduino mega 2560 with a 3.2 TFT touch screen display http://www.ebay.com/itm/SainSmart-Mega2560-3-2-TFT-Touch-LCD-SD-Reader-TFT-Shield-Kit-For-Arduino-/301352796694?pt=LH_DefaultDomain_0&hash=item462a06c216

i will attach my sketch for viewing, i just dont know how to add the DHT22 into my sketch like the temp probe that i currently have on the sketch if you take a look at it (its connected to pin 53 with address) also wasnt sure if i can have the data connected to the same data pin (53) as these temp probe are…

any help setting this dht22 up in my sketch would really help a new guy out…

P.S. i tryed the example sketch for the DHT and it works fine just not sure how to add this into my exisitng sketch… i have tryed to copy the sketch example and place them in my sketch and it just wont work for me… you will see trace of where i did that at in my sketch…

please help me out as i am really new and have no idea what or how to add some of these items into my sketch

also i would like to place it under where it says myGLCD.print(“HUMIDITY”, 174, 133);
what i mean by this is on the display screen of the tft like x and y should be like 174, 145 so when the tft is loaded it will have humidity at the top and the humidity and temp right at the bottom of it…

Vivarium_Sketch.zip (74.5 KB)

I've never used one so I can't help but must say I love the use of the word "sketching" to mean programming a sketch into an Arduino. That's my new word for programming, now. :P

i like saying sketching as it makes it sound more intelligent which i am not but who will know lol, anyways

the other sensor with address above i mention is the DS18B20 temperature sensor that is going to be connected with the same data as the dht22 just wanted to throw that in if you didnt know what temp sensor i was taking about

Hello bryanmc1988,

I reviewed your sketch very carefully and it looks like you have everything covered for your DHT22 to work,, but you don't have any code placed in the void loop section of your sketch that addresses the sensor to make it work.

See this:

void loop(){
        float h = dht.readHumidity();
        float t = dht.readTemperature();
        delay(250); //needs time to read
        float f = t*9/5 + 32;  //convert to Fahrenheit
       
        
         //print all this to your screen--you can delete this after you know your variables are printing to your lcd properly
         Serial.print("Humidity: ");
         Serial.print(h);
         Serial.print(" %\t");
         Serial.print("Temperature: ");
         Serial.print(t);
         Serial.println(" *C");
         Serial.print("Temperature: ");
         Serial.print(f);
         Serial.println(" *F");
}

Check this out, then add above variables to your LCD code to get values to your screen. As you stated, you already know the code works when tested by itself with your sensor.

good luck, houdinihar

houdinihar:
Hello bryanmc1988,

I reviewed your sketch very carefully and it looks like you have everything covered for your DHT22 to work, but you don’t have any code placed in the void loop section of your sketch that addresses the sensor to make it work.

See this:

void loop(){

float h = dht.readHumidity();
        float t = dht.readTemperature();
        delay(250); //needs time to read
        float f = t*9/5 + 32;  //convert to Fahrenheit
       
       
         //print all this to your screen–you can delete this after you know your variables are printing to your lcd properly
         Serial.print(“Humidity: “);
         Serial.print(h);
         Serial.print(” %\t”);
         Serial.print(“Temperature: “);
         Serial.print(t);
         Serial.println(” *C”);
         Serial.print(“Temperature: “);
         Serial.print(f);
         Serial.println(” *F”);
}




Check this out, then add above variables to your LCD code to get values to your screen. As you stated, you already know the code works when tested by itself with your sensor. 

good luck,
houdinihar

after adding this to the void loop, how would i place it in the right x/y place i want to?

do i just do myGLCD.print(h, 173, 147); ??? will this even work? not by my computer right now so i dont have access to my arduino to test

bryanmc1988 , I don’t use the GLCD library, so I don’t know if this will solve your question or not. You should try though:

myGLCD.print(h, 173, 147);

houdinihar