I am trying to creat a folder with today's date as the name of the folder, the esp32 will get the date from a GNSS receiver. Inside the folder creat, the esp32 will creat a .txt file and I want to name this file with the current time of the day.
I've tried doing it like this:
void createDirectory() {
Serial.println("");
Serial.println("Creating directory");
// if the folder already exists, don't bother creating it
if (!sd.exists(Date)) {
// attempt to access the root directory information
if (myDir.open("/")) {
// Create a new folder called 'testFolder'
// mkdir will return true if it completes successfully
if (sd.mkdir(Date)) {
Serial.println(F("Created 'Folder' successfully"));
} else {
Serial.println("Create 'Folder' failed");
}
} else {
Serial.println("Open 'Folder' failed");
}
} else {
Serial.println("Folder 'Folder' already exists!");
}
}
void GetTime(){
if (millis() - lastTime > 1000)
{
lastTime = millis(); //Update the timer
long latitude = myGNSS.getLatitude();
Serial.print(F("Lat: "));
Serial.print(latitude);
long longitude = myGNSS.getLongitude();
Serial.print(F(" Long: "));
Serial.print(longitude);
Serial.print(F(" (degrees * 10^-7)"));
long altitude = myGNSS.getAltitude();
Serial.print(F(" Alt: "));
Serial.print(altitude);
Serial.print(F(" (mm)"));
byte SIV = myGNSS.getSIV();
Serial.print(F(" SIV: "));
Serial.print(SIV);
Serial.println();
Serial.print(myGNSS.getYear());
Serial.print("-");
Serial.print(myGNSS.getMonth());
Serial.print("-");
Serial.print(myGNSS.getDay());
Serial.print(" ");
Serial.print(myGNSS.getHour());
Serial.print(":");
Serial.print(myGNSS.getMinute());
Serial.print(":");
Serial.print(myGNSS.getSecond());
Serial.print(" Time is ");
if (myGNSS.getTimeValid() == false)
{
Serial.print("not ");
}
Serial.print("valid Date is ");
if (myGNSS.getDateValid() == false)
{
Serial.print("not ");
}
Serial.print("valid");
Serial.println();
long day = myGNSS.getDay();
long Month = myGNSS.getMonth();
long Year = myGNSS.getYear();
Date = (day, Month, Year);
}
}
and also like this:
void createDirectory() {
Serial.println("");
Serial.println("Creating directory");
// if the folder already exists, don't bother creating it
if (!sd.exists(Date)) {
// attempt to access the root directory information
if (myDir.open("/")) {
// Create a new folder called 'testFolder'
// mkdir will return true if it completes successfully
if (sd.mkdir(Date)) {
Serial.println(F("Created 'Folder' successfully"));
} else {
Serial.println("Create 'Folder' failed");
}
} else {
Serial.println("Open 'Folder' failed");
}
} else {
Serial.println("Folder 'Folder' already exists!");
}
}
void GetTime(){
if (millis() - lastTime > 1000)
{
lastTime = millis(); //Update the timer
long latitude = myGNSS.getLatitude();
Serial.print(F("Lat: "));
Serial.print(latitude);
long longitude = myGNSS.getLongitude();
Serial.print(F(" Long: "));
Serial.print(longitude);
Serial.print(F(" (degrees * 10^-7)"));
long altitude = myGNSS.getAltitude();
Serial.print(F(" Alt: "));
Serial.print(altitude);
Serial.print(F(" (mm)"));
byte SIV = myGNSS.getSIV();
Serial.print(F(" SIV: "));
Serial.print(SIV);
Serial.println();
Serial.print(myGNSS.getYear());
Serial.print("-");
Serial.print(myGNSS.getMonth());
Serial.print("-");
Serial.print(myGNSS.getDay());
Serial.print(" ");
Serial.print(myGNSS.getHour());
Serial.print(":");
Serial.print(myGNSS.getMinute());
Serial.print(":");
Serial.print(myGNSS.getSecond());
Serial.print(" Time is ");
if (myGNSS.getTimeValid() == false)
{
Serial.print("not ");
}
Serial.print("valid Date is ");
if (myGNSS.getDateValid() == false)
{
Serial.print("not ");
}
Serial.print("valid");
Serial.println();
Date = (myGNSS.getYear()) + '-' + (myGNSS.getMonth()) + '-' + (myGNSS.getDay());
}
}