SD filename as date?
SD filename as date?
Hello,
Esp82266 running with SD library it is posible to give files a date name like 2020-4-19.csv
With the ESP32 this is not working. Esp32 is using the me-no-dev github library.
Many attempts to solve this no succes.
Dus any one has a solution?
Any help is more then welcome.
Alternatively will the use of Esp idf will do the job. Arduino no succes until now.
Like to hear.
Kind regards
ilioSS
Ps Esp32 doit devkit
Esp82266 running with SD library it is posible to give files a date name like 2020-4-19.csv
With the ESP32 this is not working. Esp32 is using the me-no-dev github library.
Many attempts to solve this no succes.
Dus any one has a solution?
Any help is more then welcome.
Alternatively will the use of Esp idf will do the job. Arduino no succes until now.
Like to hear.
Kind regards
ilioSS
Ps Esp32 doit devkit
Re: SD filename as date?
Hello pipi61
Underscore already used no succes.
In script from me-no-dev file name is
Const char * path.
String filename;
path = filename.c_str();
Here I used the underscore. No succes.
Was this your ideer as wel?
Thanks for your reply.
Regards ilioSS
Underscore already used no succes.
In script from me-no-dev file name is
Const char * path.
String filename;
path = filename.c_str();
Here I used the underscore. No succes.
Was this your ideer as wel?
Thanks for your reply.
Regards ilioSS
Re: SD filename as date?
I check https://github.com/espressif/arduino-es ... SDMMC_Test
change hello.txt to 2020-4-19.txt
results ok:
...
Writing file: /2020-4-19.txt
File written
Appending to file: /2020-4-19.txt
Message appended
Reading file: /2020-4-19.txt
Read from file: 2020-4-19 World!
Deleting file: /foo.txt
File deleted
Renaming file /2020-4-19.txt to /foo.txt
File renamed
....
and try https://github.com/espressif/arduino-es ... D_Test.ino
then works:
...
Writing file: /2020-4-19.txt
File written
Appending to file: /2020-4-19.txt
Message appended
Reading file: /2020-4-19.txt
Read from file: 2020-4-19 World!
Deleting file: /foo.txt
File deleted
Renaming file /2020-4-19.txt to /foo.txt
File renamed
Reading file: /foo.txt
Read from file: 2020-4-19 World!
...
change hello.txt to 2020-4-19.txt
results ok:
...
Writing file: /2020-4-19.txt
File written
Appending to file: /2020-4-19.txt
Message appended
Reading file: /2020-4-19.txt
Read from file: 2020-4-19 World!
Deleting file: /foo.txt
File deleted
Renaming file /2020-4-19.txt to /foo.txt
File renamed
....
and try https://github.com/espressif/arduino-es ... D_Test.ino
then works:
...
Writing file: /2020-4-19.txt
File written
Appending to file: /2020-4-19.txt
Message appended
Reading file: /2020-4-19.txt
Read from file: 2020-4-19 World!
Deleting file: /foo.txt
File deleted
Renaming file /2020-4-19.txt to /foo.txt
File renamed
Reading file: /foo.txt
Read from file: 2020-4-19 World!
...
Re: SD filename as date?
Hello pipi61
Thanks again.
I did just the same with same result.
The problem is writeFile(SD, "Hello.txt");
Howe to convert date into writeFile(SD,"2020-4-19"); ?
String handling didn't work by me.
Like to hear.
Regards ilioSS
Thanks again.
I did just the same with same result.
The problem is writeFile(SD, "Hello.txt");
Howe to convert date into writeFile(SD,"2020-4-19"); ?
String handling didn't work by me.
Like to hear.
Regards ilioSS
Re: SD filename as date?
Hello pipi61,
Here some program snippets which will explain hopefully,
Writing file: 2020-04-07
Failed to open file for writing
Save data: 98,2020-04-07,07:52:05,17.50
Appending to file: 2020-04-07
Failed to open file for appending
My idee was to handle the path the same as the message
appendFile(SD, path.c_str(), dataMessage.c_str());
Message works but the file name not.
For analize puroses it is handy to have the file on SD as 2020-4-19.csv
The problem is to have the date into the " " from "Hello.txt" like "2020-4-19.csv" challanging.
Like to hear regards ilioSS
Here some program snippets which will explain hopefully,
Code: Select all
// Write the sensor readings on the SD card
void logSDCard() {
dataPath = String(dayStamp);
String path = dataPath;
// dataPath = String(dayStamp) +"," + String(timeStamp)+ "\r\r";
dataMessage = String(readingID) + "," + String(dayStamp) + "," + String(timeStamp) + "," +
String(temperature) + "\r\n";
writeFile(SD, dataPath.c_str(), dataMessage.c_str());
Serial.print("Save data: ");
Serial.println(dataMessage);
// appendFile(SD, "/data.txt", dataMessage.c_str());
appendFile(SD, path.c_str(), dataMessage.c_str());
}
Failed to open file for writing
Save data: 98,2020-04-07,07:52:05,17.50
Appending to file: 2020-04-07
Failed to open file for appending
My idee was to handle the path the same as the message
appendFile(SD, path.c_str(), dataMessage.c_str());
Message works but the file name not.
For analize puroses it is handy to have the file on SD as 2020-4-19.csv
The problem is to have the date into the " " from "Hello.txt" like "2020-4-19.csv" challanging.
Like to hear regards ilioSS
Re: SD filename as date?
origin: Writing file:/2020-4-19.txt
your without slash:
this where?: Writing file: 2020-04-07
where dayStamp?
your without slash:
this where?: Writing file: 2020-04-07
where dayStamp?
Re: SD filename as date?
Hi pipi61,
I will test with slash as root.
Will come back with result.
Regards ilioSS
I will test with slash as root.
Will come back with result.
Regards ilioSS
Re: SD filename as date?
Hello pipi61
I just tested the filename inlcuding the / slash and IT WORKS.
I,am realy exited.
See my program snippets;
[code// Write the sensor readings on the SD card
void logSDCard() {
dataPath = String(dayStamp);
String dataPatha = "/"+ dataPath + ".csv";
String path = dataPatha;
dataMessage = String(readingID) + "," + String(dayStamp) + "," + String(timeStamp) + "," +
String(temperature) + "\r\n";
writeFile(SD, dataPath.c_str(), dataMessage.c_str());
Serial.print("Save data: ");
Serial.println(dataMessage);
appendFile(SD, path.c_str(), dataMessage.c_str());
}][/code]
Serial print result;
Reading file: /2020-04-07.csv
Read from file: 0,2020-04-07,18:48:06,23.50
1,2020-04-07,18:48:13,23.50
2,2020-04-07,18:48:20,23.50
3,2020-04-07,18:48:27,23.50
4,2020-04-07,18:48:34,23.50
5,2020-04-07,18:48:42,23.50
6,2020-04-07,18:48:49,23.50
7,2020-04-07,18:48:56,23.50
8,2020-04-07,18:49:03,23.50
9,2020-04-07,18:49:10,23.50
10,2020-04-07,18:49:17,23.50
This means that String handling is the key to have this issue solved.
Many thanks to you to put me on the correcr track.
Kind regards,
ilioSS
Note: for me this issue can be closed.
I just tested the filename inlcuding the / slash and IT WORKS.
I,am realy exited.
See my program snippets;
[code// Write the sensor readings on the SD card
void logSDCard() {
dataPath = String(dayStamp);
String dataPatha = "/"+ dataPath + ".csv";
String path = dataPatha;
dataMessage = String(readingID) + "," + String(dayStamp) + "," + String(timeStamp) + "," +
String(temperature) + "\r\n";
writeFile(SD, dataPath.c_str(), dataMessage.c_str());
Serial.print("Save data: ");
Serial.println(dataMessage);
appendFile(SD, path.c_str(), dataMessage.c_str());
}][/code]
Serial print result;
Reading file: /2020-04-07.csv
Read from file: 0,2020-04-07,18:48:06,23.50
1,2020-04-07,18:48:13,23.50
2,2020-04-07,18:48:20,23.50
3,2020-04-07,18:48:27,23.50
4,2020-04-07,18:48:34,23.50
5,2020-04-07,18:48:42,23.50
6,2020-04-07,18:48:49,23.50
7,2020-04-07,18:48:56,23.50
8,2020-04-07,18:49:03,23.50
9,2020-04-07,18:49:10,23.50
10,2020-04-07,18:49:17,23.50
This means that String handling is the key to have this issue solved.
Many thanks to you to put me on the correcr track.
Kind regards,
ilioSS
Note: for me this issue can be closed.
Who is online
Users browsing this forum: No registered users and 39 guests