• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

Wrong creation time for MicroSD files

Q&A Forum › Wrong creation time for MicroSD files
0 Vote Up Vote Down
Enrico asked 1 year ago
4 Answers
0 Vote Up Vote Down
Enrico answered 1 year ago

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

0 Vote Up Vote Down
Sara Santos Staff answered 1 year ago

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
 

0 Vote Up Vote Down
Enrico answered 1 year ago

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

0 Vote Up Vote Down
Sara Santos Staff answered 1 year ago

Ok.
Thanks for the feedback.
I’ll mark this issue as resolved. If you need further help, you just need to open a new question in our forum.
Regards,
Sara

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [eBook Updated] Learn Raspberry Pi Pico/Pico W with MicroPython eBook – Version 1.2 May 26, 2025
  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.