Date and time simultaneously on UTFT and SD

Hello.

I need advice. I have a program that reads the status of the sensor 1 and 2.
Status then displayed on the UTFT:

2015.2.1 3:00:00 p.m. Status1 State2 time 3sec

I need at the same time the state saved on an SD card into the file.

I added the library:
#include <UTFT.h>
#include <Wire.h>
#include “RTClib.h”
#include <SPI.h>
#include <SD.h>

It is still OK, but once define the function:

File myFile;

and stops working time RTC. The display will then show only status 1 and 2 and the data is not saved.

Probably about the conflicts in the library RTClib.hs SD.h, SPI.h

You do not know how to solve it or how else simply write data to a file with time?

thanks

Probably about the conflicts in the library RTClib.hs SD.h, SPI.h

Probably NOT. Most likely, you've run out of memory. But, no code == no help.

#include <UTFT.h>
#include <Wire.h>
#include “RTClib.h”
#include <SPI.h>
#include <SD.h>

int i = 0;
String stav1="";
String stav2="";
int sekunda2=0;
int minuta2=0;
int hodina2=0;
int cas_vysledek2=0;

extern uint8_t SmallFont;

UTFT myGLCD(ITDB28,19,18,17,16); //TFT

RTC_Millis rtc; //hodiny

void setup()
{
myGLCD.InitLCD();
myGLCD.clrScr();
myGLCD.setFont(SmallFont);

rtc.adjust(DateTime(F(DATE), F(TIME)));
rtc.begin(DateTime(F(DATE), F(TIME)));
}

void loop()
{
String data="";
String data2="";
String data_cas="";
String dataString = “”;
String dataString2 = “”;

myGLCD.setColor(255, 255, 0);
myGLCD.setFont(SmallFont);
myGLCD.print(“LOGGER”, 100, 0, 0);
myGLCD.print("***************************************", 0, 20, 0);
myGLCD.print(" Datum Cas Sen1 Sen2 Cas “, 0, 30, 0);
myGLCD.print(”---------------------------------------", 0, 40, 0);

// sensor 1
int sensor = analogRead(0);
// dataString += String(sensor);
if (sensor < 500) {
dataString = “ON”;
}
else{
dataString = “OFF”;
}
// sensor 2
int sensor2 = analogRead(1);
// dataString += String(sensor);
if (sensor2 < 500) {
dataString2 += “ON”;
}
else{
dataString2 += “OFF”;
}

DateTime now = rtc.now();

String rok = “”;
rok += now.year();
String mesic = “”;
mesic += now.month();
String den = “”;
den += now.day();
String hodina = “”;
hodina += now.hour();
String minuta = “”;
minuta += now.minute();
String sekunda = “”;
sekunda += now.second();

int time_sec1 = now.second();
int time_min1 = now.minute()*60;
int time_hod1 = now.hour()*3600;

int cas_vysledek1 = time_hod1 + time_min1 + time_sec1;
int cas = 0;

cas = cas_vysledek1 - cas_vysledek2;
data = rok + “.” + mesic + “.” + den + " " + hodina + “:” + minuta + “:” + sekunda;
data_cas += cas;

if (sensor > 500 || sensor2 > 500) {

if (dataString != stav1 || dataString2 != stav2) {

myGLCD.setColor(0, 255, 255);
myGLCD.print(" “, 0, 50+i, 0);
myGLCD.print(data, 0, 50+i, 0);
myGLCD.print(dataString, 170, 50+i, 0);
myGLCD.print(dataString2, 210, 50+i, 0);
myGLCD.setColor(0, 255, 0);
myGLCD.print(”---------------------------------------", 0, 60+i, 0);

i = i + 10;

if (i > 170) { //max pocet radku na TFT
i = 0;
}
stav1 = dataString;
stav2 = dataString2;

sekunda2 = now.second();
minuta2 = now.minute()*60;
hodina2 = now.hour()*3600;
cas_vysledek2 = hodina2 + minuta2 + sekunda2;
}
else{

int data_cas2a = (cas / 60);
String data_cas2 = " ";

int data_cas3a = cas % 60;

String nula;
if(data_cas3a < 10){
nula = “0”;
}
else{
nula = “”;
}

String data_cas3;
String dt=":";
data_cas3 += data_cas2a + dt + nula + data_cas3a;

myGLCD.print(data_cas2, 260, 40+i, 0);
myGLCD.print(data_cas3, 260, 40+i, 0);
}

}
else {
stav1 = “ON”;
stav2 = “ON”;
data_cas = “0”;
}

// while (true) {};
delay(10);
}

Works independently me either saving to SD file or extract data to display UTFT. Once this program will define:

"File myFile ...."

I used the example http://arduino.cc/en/Tutorial/Datalogger

So stop working display the time and date will not be saved ....

      String data="";
      String data2="";
      String data_cas="";
      String dataString = "";
      String dataString2 = "";

Did you get the super-secret two terabyte Arduino? If not, this crap has NO place on the Arduino. Use NULL terminated arrays of chars, and quit pissing away memory.

When I limited the damages to a minimum, so now it works somehow, just have to change. Thanks for your help ....