I'm trying to save data to files on an SD card. The SD card works fine and I can save to a text file in the root directory. But I would like to save to a file in a subdirectory.
My function that saves the temperature is below. I can't get the following line to behave:
Changing the back slashes () to forward slashes (/) did the trick. String logfilePath = "logs_tmprt/tmprt_" + getFormattedDate() + ".txt";
Seems like I don't need the first "/" ? I'll try both ok.
I'll also try the "logfilePath.c_str()" suggestion. Saves a few lines and looks nicer.
But the code works fine now, thanks!
@alto777 I guess you mean if I can use "moreThenEightCharacters.txt" as a filename?
The filename saves correctly as "tmprt_2022.07.09.txt". So that would be 15.3 and yes that works.
Depends what your current directory is when you call it. Preceding with a / will always be with reference to the root directory. Without the / the path will be applied to the current directory. If your current directory happens to be the filesystem root then both versions will find the same file, but if your code happens to change directory, your logging process may end up looking for /current/directory/logs_tmprt/tmprt_"...etc instead. If the logs are always in /logs_imprt/, then its probably best to precede with / so you know that the process is looking to save or write to the correct file in he correct location.