Arduino datalogger geen data

Beste Arduinokenners,

ik ben bezig met een project om een datalogger te maken. Hierbij is het probleem dat ik geen informatie kan uithalen in de datalogger. iemand idee waar het aan ligt.?

#include <DS1307RTC.h>
#include "TimeLib.h"
#include <Wire.h>
#include <SPI.h>
#include <SD.h>

File myFile;
const int chipSelect = 10;

String time ;
tmElements_t tm;

void setup() {
Serial.begin(9600);
while (!Serial) ; // wait for serial
delay(200);
Serial.println("ArduinoAll DataLogger Shield Test");
pinMode(SS, OUTPUT);

if (!SD.begin(chipSelect)) {
Serial.println("SD Card initialization failed!");
return;
}
Serial.println("SD Card OK.");
ReadText();
}

void loop() {
time = Now()+" Sensor Value";
Serial.println(time);
WriteText(time);
delay(3000);
}

void ReadText(){
// re-open the file for reading:
myFile = SD.open("test.txt");
if (myFile) {
Serial.println("test.txt:");

// read from the file until there's nothing else in it:
while (myFile.available()) {
Serial.write(myFile.read());
}
// close the file:
myFile.close();
}
else {
// if the file didn't open, print an error:
Serial.println("error opening test.txt");
}
}

void WriteText(String txt){
myFile = SD.open("test.txt", FILE_WRITE);
if (myFile) {
myFile.println(txt);
myFile.close();
}
else {
// if the file didn't open, print an error:
Serial.println("error opening test.txt");
}
}

String Now(){
String time = "";
if (RTC.read(tm)) {
// time = String(tm.Hour+":"+tm.Minute+":"+tm.Secnd+" DAY : "+tm.Day+"/"+tm.Month+"/"+tmYearToCalendar(tm.Year));
time+=tm.Hour;
time+=":";

time+=tm.Minute;
time+=":";

time+=tm.Second;
time+=" DAY : ";

time+=tm.Day;
time+="/";

time+=tm.Month;
time+="/";

time+=tmYearToCalendar(tm.Year);
}
else {
time = "NO";
if (RTC.chipPresent()) {
Serial.println("The DS1307 is stopped. Please run the SetTime");
Serial.println("example to initialize the time and begin running.");
Serial.println();
}
else {
Serial.println("DS1307 read error! Please check the circuitry.");
Serial.println();
}
}
return time;
}

ik snap if (myfile) nietzoek eens een voorbeeld dat wel werkt, en kijk of de lib ook bij jouw shield hoort, dus wat gaat er wel en niet goed.

Beste lezers,

ik heb hierbij een nieuwere code gemaakt omdat de andere niet werkte. weet iemand waarom myFile niet gevonden kan worden?. de error is 'myFile' does not name a type.

#include <Wire.h>
#include "RTClib.h"
#include <SD.h>
#include <SPI.h>

RTC_DS3231 rtc;

char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

File myFile;

void setup () {

#ifndef ESP8266
while (!Serial); // for Leonardo/Micro/Zero
#endif

Serial.begin(9600);

delay(3000); // wait for console opening

if (! rtc.begin()) {
Serial.println("Couldn't find RTC");
while (1);
}

if (rtc.lostPower()) {
Serial.println("RTC lost power, lets set the time!");
// following line sets the RTC to the date & time this sketch was compiled
rtc.adjust(DateTime(F(DATE), F(TIME)));
// This line sets the RTC with an explicit date & time, for example to set
// January 21, 2014 at 3am you would call:
// rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
}
}
myFile = SD.open("test.txt", FILE_WRITE);

void loop () {
DateTime now = rtc.now();

Serial.print(now.day(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.year(), DEC);
Serial.print(" (");
Serial.print(daysOfTheWeek[now.dayOfTheWeek()]);
Serial.print(") ");
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.println();

myFile.print(now.day(), DEC);
myFile.print('/');
myFile.print(now.month(), DEC);
myFile.print('/');
myFile.print(now.year(), DEC);
myFile.print(" (");
myFile.print(daysOfTheWeek[now.dayOfTheWeek()]);
myFile.print(") ");
myFile.print(now.hour(), DEC);
myFile.print(':');
myFile.print(now.minute(), DEC);
myFile.print(':');
myFile.println();
Serial.println();
delay(3000);

}

jij schrijft myfile. en dan commandos maar er is geen library die dit als commando leest en dus zegt de compiler dat er geen type is voor myfile.