Hi,
in an ESP32 WebServer project that saves sensor readings on a MicroSD card file, the creation time of a new file (seen loading the SD card on a Linux laptop) is set ONE HOUR in the future!
The time stamps written inside the file are right, as well the times displayed on a chart, but the creation/modification time of the files inside the SD card are NOT.
On my ESP32 project I have initialized the local timezone (Europe/Zurich) using code found in other RTNLAB tutorials:
initTime("CET-1CEST,M3.5.0,M10.5.0/3");
printLocalTime();
The printLocalTime() inside the setup() displays also the right time.
How can I let the SD code write the right file creation/modification time on the MicroSD card?
Is the SD.h code using another time as the rest of the ESP32 code?
Many thanks!
Best regards,
Enrico
Hi.
I’m not sure, but I think you need to synchronize the ESP32 internal clock.
I think you need to use something like it’s explained on this example: https://github.com/espressif/arduino-esp32/blob/master/libraries/ESP32/examples/Time/SimpleTime/SimpleTime.ino
Check line 70.
I hope this helps.
Let me know if this works.
Regards,
Sara
Hi Sara,
many thanks for your answer.
I have tested the changes that you suggested, but there is no different behavior in the ESP32 server.
But finally it seems not to be a real issue, because if I add to the program a call to the function that returns the last modification timestamp, the returned value is correct as well when I take the MicroSD card and check it on a PC with Windows 11.
The problem seems only to be with Linux, where the system seems to consider the SD card timestamps to be UTC values by default and then it adds the timezone offset, in my case +1 hour. The same problem seems to be for photo camera users, that load the SD card on a PC with Linux.
Best regards,
Enrico