Displaying DS3231 temp display on tft

I am new to arduino and still trying hard to learn the basics.

I am making a touchscreen temperature sensor for my boats control panel. I have made good progress so far although I am stumped at the following -

I have managed to display the date and time from the DS3231 on my 4.3 sainsmart with no problems although I cant seem to display the reading from the onboard temperature sensor in the same way.

It is printing in serial monitor with no problems but I just cant seem to display this info on my tft.

I am using the command : -

myGLCD.print(rtc.getTemp(), 180, 78);

which just results in a compiling error.

As stated I can display the time and date no problem with similar commands : -

myGLCD.print(rtc.getDateStr(), 355, 73);
myGLCD.print(rtc.getDOWStr(), 60, 73);
myGLCD.setColor (255,255,255);
myGLCD.setFont(BigFont);
myGLCD.print(rtc.getTimeStr(), 180, 71);

As i say I am a complete beginner and I have probably made a schoolboy error, can someone please point out what I am missing and put me out my misery :slight_smile:

Is also my first post so I hope I have uploaded my sketch properly. edit - I tried posting my code using the code command but just displays a blank scroll box :confused:
Im sorry to have to include my sketch in this way

#include <DS3231.h>
#include <UTFT.h>
#include <UTouch.h>
#include <UTFT_tinyFAT.h>
#include <tinyFAT.h>

extern uint8_t SmallFont[];
extern uint8_t BigFont[];
extern uint8_t SevenSegNumFont[];

char* files480[]={"pic998.RAW, pic1000.RAW"};

char* files[10];

int picsize_x, picsize_y;

word res;
long sm, em;

UTFT myGLCD(ITDB43,38,39,40,41);
UTFT_tinyFAT myFiles(&myGLCD);
DS3231 rtc(SDA, SCL);
UTouch myTouch( 6, 5, 4, 3, 2);

void setup()
{
Serial.begin(115200);

myGLCD.InitLCD();
file.initFAT();

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

myGLCD.setColor(255,255,255);
myGLCD.setFont(SmallFont);
picsize_x=myGLCD.getDisplayXSize();
picsize_y=myGLCD.getDisplayYSize();
switch (picsize_x)
{
for (int z=0; z<sizeof(files480)/sizeof(*files480);z++)
files[z] = files480[z];
}

}

void loop()

{
int buf[478];
int x, x2;
int y, y2;
int r;

int var = 0;

// DRAW THE PATTERN AND LOGO

myGLCD.clrScr();
myGLCD.setColor (255,0,0);
for (int i=15; i<256; i+=5)
{
myGLCD.drawLine(1, i, (i1.88)-10, 256);
}
myGLCD.setColor (255,0,0);
for (int i=256; i>15; i-=5)
{
myGLCD.drawLine(478, i, (i
1.88)-11, 15);
}
myGLCD.setColor (0,255,255);
for (int i=256; i>15; i-=5)
{
myGLCD.drawLine(1, i, 491-(i1.88), 15);
}
myGLCD.setColor (0,255,255);
for (int i=15; i<256; i+=5)
{
myGLCD.drawLine(478, i, 490-(i
1.88), 256);
}
{
res=myFiles.loadBitmap(75, 105, 330, 60, "pic1000.RAW");
}
delay(5000);

myGLCD.clrScr();

// DRAW THE MAIN SCREEN

{
myGLCD.setBackColor (0,0,0);
res=myFiles.loadBitmap(0, 0, picsize_x, picsize_y, "pic998.RAW");
while(var < 200)
{

// DRAW TIME, DAY & DATE

myGLCD.setFont(SmallFont);
myGLCD.setColor (255,255,255);
//myGLCD.print(rtc.getTemp(), 180, 78);
myGLCD.print(rtc.getDateStr(), 355, 73);
myGLCD.print(rtc.getDOWStr(), 60, 73);
myGLCD.setColor (255,255,255);
myGLCD.setFont(BigFont);
myGLCD.print(rtc.getTimeStr(), 180, 71);

{
// SEND TEMPRATURE TO SERIAL MONITOR
Serial.print("Temperature: ");
Serial.print(rtc.getTemp());
Serial.println(" C");

}

}}}

not sure if I am way off track considering serial monitor can read the data, but would I need the wire library for this?

See this manual: utft/UTFT.pdf at master · telamon/utft · GitHub

I think that, to print the temperature, you will need printNumF() and not print().

Look up printNumF in the manual.

Thank you, I will check out that info and post my findings :slight_smile:

That seems to be the same manual that I have, I just tried printNumF but still the same :frowning:
I see that it mentions it being a float type.
Does that mean i would have to set up a float first in my sketch?
sorry if these seem to be daft questions, i am a complete beginner
Thanks

Your print options are,

printNumI(long num, int x, int y, int length, char filler)

and

printNumF(double num, byte dec, int x, int y, char divider, int length, char filler)

also

print(char *st, int x, int y, int deg)

the ones in bold are usually left untouched, but you can play with them to see what they do.

Question, where did you download your DS3231 library?

What does your code look like now?

Did you remember to set the value of dec in the printNumF() function? (Take another look at the manual.)

Right, maybe a little progress but not exactly where i want to be yet :confused:

I am going to be measuring a few temperatures with lm35's
I used printNumF for one of these and got it to work using the following : -

myGLCD.printNumF(cel, 1, CENTER, 0); // to 1 decimal place

however this command doesnt work with the RS3231 temp sensor for some reason.
I have been trying : -

myGLCD.printNumF(rtc.getTemp, 1, CENTER, 0);

but then just as I was typing this I realized it should have brackets >:(
a beginners mistake and so frustrating that it was this simple.

so thankfully I now have it working using the following : -

myGLCD.printNumF(rtc.getTemp(), 1, CENTER, 0);

I couldnt have done this without you guys so thank you very much and no doubt I will have more beginners questions in the future.

Thank you

The UTFT library I am using : -

http://www.rinkydinkelectronics.com/library.php?id=51

#include <DS3231.h>
#include <SD.h>
#include<SPI.h>
#include "Wire.h"
#include <UTFT.h>
#include <UTouch.h>
.
.
.

myGLCD.setFont(BigFont);
myGLCD.setColor(255, 255, 255);
myGLCD.print(rtc.getDOWStr(), 0, 0);
.
.
.

DOES NOT WORK.
Anyone has a sollution ?
Tanx in advance ! :slight_smile: