Trying to display temperature on a TFT [SOLVED]

Hi, I have an Arduino Nano connected to a DHT11 temperature sensor and a 1.8" TFT display. I'm trying to display the temperature detected in Fahrenheit and have it be displayed onto the TFT's screen. But when I upload the sketch it just keeps displaying the number 824 were the temperature is suppose to be (btw I've copied some pieces from other sketches).

#include <idDHT11.h>

int idDHT11pin = 2; //Digital pin for comunications
int idDHT11intNumber = 0; //interrupt number (must be the one that use the previus defined pin (see table above)

//declaration
void dht11_wrapper(); // must be declared before the lib initialization

// Lib instantiate
idDHT11 DHT11(idDHT11pin,idDHT11intNumber,dht11_wrapper);

#include <TFT.h>  // Arduino LCD library
#include <SPI.h>

// pin definition for the Uno
#define cs   10
#define dc   9
#define rst  8  

// pin definition for the Leonardo
// #define cs   7
// #define dc   0
// #define rst  1 


TFT TFTscreen = TFT(cs, dc, rst);


char sensorPrintout[4];


void setup() {
  
  // Put this line at the beginning of every sketch that uses the GLCD:
  TFTscreen.begin();

 
  TFTscreen.background(0, 0, 0);
  
  
  TFTscreen.stroke(255,255,255);

  TFTscreen.setTextSize(1);

  TFTscreen.text("Temperature Now :\n ",0,0);
  
  TFTscreen.setTextSize(3);

 Serial.begin(9600);
  Serial.println("idDHT11 Example program");
  Serial.print("LIB version: ");
  Serial.println(IDDHT11LIB_VERSION);
  Serial.println("---------------");
} 
  void dht11_wrapper() {
  DHT11.isrCallback();
}

void loop()
{
  Serial.print("\nRetrieving information from sensor: ");
  Serial.print("Read sensor: ");
  //delay(100);
  DHT11.acquire();
  while (DHT11.acquiring())
    ;
  int result = DHT11.getStatus();
  switch (result)
  {
  case IDDHTLIB_OK: 
    Serial.println("OK"); 
    break;
  case IDDHTLIB_ERROR_CHECKSUM: 
    Serial.println("Error\n\r\tChecksum error"); 
    break;
  case IDDHTLIB_ERROR_ISR_TIMEOUT: 
    Serial.println("Error\n\r\tISR Time out error"); 
    break;
  case IDDHTLIB_ERROR_RESPONSE_TIMEOUT: 
    Serial.println("Error\n\r\tResponse time out error"); 
    break;
  case IDDHTLIB_ERROR_DATA_TIMEOUT: 
    Serial.println("Error\n\r\tData time out error"); 
    break;
  case IDDHTLIB_ERROR_ACQUIRING: 
    Serial.println("Error\n\r\tAcquiring"); 
    break;
  case IDDHTLIB_ERROR_DELTA: 
    Serial.println("Error\n\r\tDelta time to small"); 
    break;
  case IDDHTLIB_ERROR_NOTSTARTED: 
    Serial.println("Error\n\r\tNot started"); 
    break;
  default: 
    Serial.println("Unknown error"); 
    break;
  }


  Serial.print("Temperature (oF): ");
  Serial.println(DHT11.getFahrenheit(), 2);


  delay(20);



  // Read the value of the sensor on A0

  String yo = String('DHT11.getFahrenheit(), 2');
 

  yo.toCharArray(sensorPrintout, 4);

  
  TFTscreen.stroke(255,255,255);
  
  TFTscreen.text(sensorPrintout, 0, 20);

  delay(2500);

  TFTscreen.stroke(0,0,0);
  TFTscreen.text(0, 0, 20);

}
String yo = String('DHT11.getFahrenheit(), 2');

Look carefully.

Hmm, I think you were referring to the quotations, so I've changed them to double quotations but now the TFT just displays the letters DHT where the temperature is supposed to be.

There's also a similar issue on the line that reads:

Serial.println(DHT11.getFahrenheit(), 2);

That "2" means to display the value in binary doesn't it? I'm also still learning so I may be wrong.

KenF I honestly wouldn't know since I am a noob at this, but I will try to modify that 2.

Update: I've tried removing the 2 from the serial.print line and it come out with an error. I also tried deleting the 2 in the string line and I'm still just displaying the letters DHT where the temperature is supposed to be.

I've been working with the DHT11 for my current project. I've since changed over to a different chip for temperature (as the dht11 only gives temperature to the nearest whole degree centigrade. I'll see if I can find the code I WAS using.

Honestly I would be happy If it would even display the nearest whole degree centigrade. I don't think 824 is correct, and when I look at the serial monitor the sensor is displaying reasonable values.

Update: I've tried removing the 2 from the serial.print line and it come out with an error. I also tried deleting the 2 in the string line and I'm still just displaying the letters DHT where the temperature is supposed to be.

Please feel free to post your code

OK
Something like this should work

dht11 DHT11;
//in the following line replace 53 with the pin you're using
int chk=DHT11.read(53);
if (chk==DHTLIB_OK)
    {//get humidity
     int hum=DHT11.humidity;
    //get temperature in centigrade
    int temp=DHT11.temperature;
    //if you want it in farenheight..
    temp=32+temp*9/5;
    Serial.println(temp,DEC);
    }
String yo = String('DHT11.getFahrenheit');

^ This modification keeps giving me the number 269

String yo = String("DHT11.getFahrenheit"

^ That gives me the letters DHT

String yo = String("DHT11.getFahrenheit(), 2");

^also gives the letters DHT

  Serial.println(DHT11.getFahrenheit);

^this gives me the error no matching function for call to 'HardwareSerial::println()'

-Sidenote: Thanks Ken I'll try your code out right now.

KenF, I am trying to incorporate your code but I get an error for the line

  dht11 DHT11;

it tells me that 'dt11' was not declared in this scope

Am I missing a library or something? I remember seeing this same line on an instructables project.

^this gives me the error no matching function for call to 'HardwareSerial::println()'

Maybe you could try calling the function

I apologize for my ignorance, but could you please explain what calling a function means and how I would apply it to my sketch?

Serial.println(DHT11.getFahrenheit());

Hmm, I applied the line of code you provided and the serial monitor continues to put out reasonable values but the display continues to show the number 824.

Maybe it's a bit warm where you are.
I do Kelvin or Celsius, but have no concept of Fahrenheit.

Or, you could post your code.

Well my serial monitor display this:
Retrieving information from sensor: Read sensor: OK
Temperature (oF): 77.00

Here is my current code ( I think this is what you were asking for)

#include <idDHT11.h>

int idDHT11pin = 2; //Digital pin for comunications
int idDHT11intNumber = 0; //interrupt number (must be the one that use the previus defined pin (see table above)

//declaration
void dht11_wrapper(); // must be declared before the lib initialization

// Lib instantiate
idDHT11 DHT11(idDHT11pin,idDHT11intNumber,dht11_wrapper);

#include <TFT.h>  // Arduino LCD library
#include <SPI.h>

// pin definition for the Uno
#define cs   10
#define dc   9
#define rst  8  

// pin definition for the Leonardo
// #define cs   7
// #define dc   0
// #define rst  1 

// create an instance of the library
TFT TFTscreen = TFT(cs, dc, rst);

// char array to print to the screen
char sensorPrintout[4];


void setup() {
  

  
  // Put this line at the beginning of every sketch that uses the GLCD:
  TFTscreen.begin();

  // clear the screen with a black background
  TFTscreen.background(0, 0, 0);
  
  // write the static text to the screen
  // set the font color to white
  TFTscreen.stroke(255,255,255);
  // set the font size
  TFTscreen.setTextSize(1);
  // write the text to the top left corner of the screen
  TFTscreen.text("Temperature Now :\n ",0,0);
  // ste the font size very large for the loop
  TFTscreen.setTextSize(3);

 Serial.begin(9600);
  Serial.println("idDHT11 Example program");
  Serial.print("LIB version: ");
  Serial.println(IDDHT11LIB_VERSION);
  Serial.println("---------------");
} 
  void dht11_wrapper() {
  DHT11.isrCallback();
}

void loop()
{
  Serial.print("\nRetrieving information from sensor: ");
  Serial.print("Read sensor: ");
  //delay(100);
  DHT11.acquire();
  while (DHT11.acquiring())
    ;
  int result = DHT11.getStatus();
  switch (result)
  {
  case IDDHTLIB_OK: 
    Serial.println("OK"); 
    break;
  case IDDHTLIB_ERROR_CHECKSUM: 
    Serial.println("Error\n\r\tChecksum error"); 
    break;
  case IDDHTLIB_ERROR_ISR_TIMEOUT: 
    Serial.println("Error\n\r\tISR Time out error"); 
    break;
  case IDDHTLIB_ERROR_RESPONSE_TIMEOUT: 
    Serial.println("Error\n\r\tResponse time out error"); 
    break;
  case IDDHTLIB_ERROR_DATA_TIMEOUT: 
    Serial.println("Error\n\r\tData time out error"); 
    break;
  case IDDHTLIB_ERROR_ACQUIRING: 
    Serial.println("Error\n\r\tAcquiring"); 
    break;
  case IDDHTLIB_ERROR_DELTA: 
    Serial.println("Error\n\r\tDelta time to small"); 
    break;
  case IDDHTLIB_ERROR_NOTSTARTED: 
    Serial.println("Error\n\r\tNot started"); 
    break;
  default: 
    Serial.println("Unknown error"); 
    break;
  }


  Serial.print("Temperature (oF): ");
  Serial.println(DHT11.getFahrenheit());


  delay(20);



  // Read the value of the sensor on A0

  String yo = String('DHT11.getFahrenheit(), 2');
 
  // convert the reading to a char array
  yo.toCharArray(sensorPrintout, 4);

  // set the font color
  TFTscreen.stroke(255,255,255);
  // print the sensor value
  TFTscreen.text(sensorPrintout, 0, 20);
  // wait for a moment
  delay(2500);
  // erase the text you just wrote
  TFTscreen.stroke(0,0,0);
  TFTscreen.text(0, 0, 20);



}

And yes the weather is pretty warm around here.

String yo = String('DHT11.getFahrenheit(), 2');

I thought we'd covered this.

If anyone knows how to fix this, it would be greatly appreciated!

Robtillart has published a much easier library to use.. Try it instead...
I might point out that the DHT22 is a much better device to use.
Although a bit more expensivehttp://www.ebay.com/itm/DHT22-AM2302-Digital-Temperature-and-Humidity-Sensor-/120770206870

Doc