3.2"TFT - Trying to print the Time/Humidity/Temp problems.

So I’m using a 3.2" TFT and I have it working wonders (after many hours trying to figure it out as I’m still a new to this) but the one thing I can’t seem to do it to print variables like the current time from my RTC or my Humidity/Temp from my HTC11. Anyone able to shed some light on this for me.

I put a bunch of “****” near the code that is most likely needs to be changed. After typing this out I realized that the reason it isn’t working is the “h” and “t” variables aren’t being called into the functions, which I’m not sure how to do.

Thanks

~Wayne

CODE: (I deleted a lot of filler that I know isn’t the problem)

#include <UTFT.h>
#include <UTouch.h>

#include <Wire.h>
#include “RTClib.h”
#include “DHT.h” //DHT Libary
#define DHTPIN 8 // what pin we’re connected to
#define DHTTYPE DHT11 // DHT 11
#define RELAY1 12 //Humidity control
#define RELAY2 11 //UVA Bulb
#define RELAY3 10 //Heat Pat
#define RELAY4 9 //Daytime Light
#define RELAY_ON 0
#define RELAY_OFF 1
float Hour = 0;
float C = 0;
float V = 0;
DHT dht(DHTPIN, DHTTYPE);
RTC_DS1307 RTC;

UTFT myGLCD(ITDB32S,38,39,40,41);

UTouch myTouch( 6, 5, 4, 3, 2);

// Declare which fonts we will be using
extern uint8_t SmallFont;

int x, y;
char stCurrent[20]="";
int stCurrentLen=0;
char stLast[20]="";

void drawButtons()
{
//Top Row (Two Buttons)
myGLCD.setColor(0, 0, 255);
myGLCD.fillRoundRect (10,10, 150, 60);
myGLCD.setColor(255, 255, 255);
myGLCD.drawRoundRect (10, 10, 150, 60);
myGLCD.print(“Bearded Dragon”, 20, 35);
myGLCD.setColor(0, 0, 255);
myGLCD.fillRoundRect (160, 10, 300, 60);
myGLCD.setColor(255, 255, 255);
myGLCD.drawRoundRect (160, 10, 300, 60);
myGLCD.print(“Ball Python”, 170, 35);
myGLCD.setBackColor (0, 0, 0);

//Middle Row (Two Text Boxes)
myGLCD.setColor(0, 0, 255);
myGLCD.fillRoundRect (10, 70, 150, 130);
myGLCD.setColor(255, 255, 255);
myGLCD.drawRoundRect (10, 70, 150, 130);

//******************************************************************
myGLCD.print(h, 20, 115);
//******************************************************************
myGLCD.setColor(0, 0, 255);
myGLCD.fillRoundRect (160, 70, 300, 130);
myGLCD.setColor(255, 255, 255);
myGLCD.drawRoundRect (160, 70, 300, 130);
//******************************************************************
myGLCD.print(t, 170, 115);
//******************************************************************
myGLCD.setBackColor (0, 0, 0);

//Bottom Text Block
myGLCD.setColor(0, 0, 255);
myGLCD.fillRoundRect (10, 140, 300, 230);
myGLCD.setColor(255, 255, 255);
myGLCD.drawRoundRect (10, 140, 300, 230);
myGLCD.print(“Clear”, 40, 147);
myGLCD.setColor(0, 0, 255);
myGLCD.setBackColor (0, 0, 0);
}

void updateStr(int val)
{
if (stCurrentLen<20)
{
stCurrent[stCurrentLen]=val;
stCurrent[stCurrentLen+1]=’\0’;
stCurrentLen++;
myGLCD.setColor(0, 255, 0);
myGLCD.print(stCurrent, LEFT, 224);
}
else
{
myGLCD.setColor(255, 0, 0);
myGLCD.print(“BUFFER FULL!”, CENTER, 192);
delay(500);
myGLCD.print(" “, CENTER, 192);
delay(500);
myGLCD.print(“BUFFER FULL!”, CENTER, 192);
delay(500);
myGLCD.print(” ", CENTER, 192);
myGLCD.setColor(0, 255, 0);
}
}

// Draw a red frame while a button is touched
void waitForIt(int x1, int y1, int x2, int y2)
{
myGLCD.setColor(255, 0, 0);
myGLCD.drawRoundRect (x1, y1, x2, y2);
while (myTouch.dataAvailable())
myTouch.read();
myGLCD.setColor(255, 255, 255);
myGLCD.drawRoundRect (x1, y1, x2, y2);
}

void setup ()
{
Serial.begin(9600);
Wire.begin();
RTC.begin();
dht.begin();
// RTC.adjust(DateTime(DATE, TIME)); //uncomment this to set time
digitalWrite(RELAY1, RELAY_OFF);
digitalWrite(RELAY2, RELAY_OFF);
digitalWrite(RELAY3, RELAY_OFF);
digitalWrite(RELAY4, RELAY_OFF);

pinMode(RELAY1, OUTPUT);
pinMode(RELAY2, OUTPUT);
pinMode(RELAY3, OUTPUT);
pinMode(RELAY4, OUTPUT);

// Initial setup
myGLCD.InitLCD();
myGLCD.clrScr();

myTouch.InitTouch();
myTouch.setPrecision(PREC_MEDIUM);

myGLCD.setFont(SmallFont);
myGLCD.setBackColor(0, 0, 255);
drawButtons();

}
void loop ()
{
DateTime now = RTC.now(); //Takes the time from the RTC

//******************************************************************
float Month = now.month();
float Hour = now.hour(); // Get the hours right now and store them in an integer called h
float Min = now.minute(); // Get the minutes right now and store them in an integer called m
float Sec = now.second(); // Get the seconds right now and store them in an integer called s

float h = dht.readHumidity(); // Read humidity
float t = dht.readTemperature(); // Read temperature as Celsius

//******************************************************************

//and it continues for another 500+ lines.

float is a poor choice for month, hour, min, sec since they will only ever be integers?

Regards,

Graham

myGLCD.printNumI(data, X, Y); myGLCD.printNumF(data. decimal, X, Y);

If you open the libraries and look at the .h file, you can see all the available functions.

Wayneedouglas: or my Humidity/Temp from my HTC11.

Assuming the numbers are floats, your code should be something like

  myGLCD.printNumF(DrainTemp, 2, 180, 150);

This is explained on p7 of the UTFT manual