• 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

Setting Date and time – file on SD card

Q&A Forum › Category: ESP8266 › Setting Date and time – file on SD card
0 Vote Up Vote Down
Rick Lutz asked 6 years ago

I have a having a hard time getting the date/time set when creating a file on a SD card on an 8266.  I am using the SD.h and tried including sdfat.H but i keep getting an error ” ‘FAT_DATE’ was not declared in this scope”.

My code from the net:

void dateTime(uint16_t* date, uint16_t* time)
{
*date = FAT_DATE(year, month, day);
*time = FAT_TIME(hour, minute, second);
}

I included fatStructs and found a new error…………….

I cannot find a way to set the time an date on a file created on the SD card.  Searched RNTlab and have found no answers.  I would like to find the code to set date/time and then incorporate NTP or RTC time.

can you point me to a working set of code? Seems I need several libraries to make it work – missing something fundamental.

Question Tags: ESP8266 SD Card Date Time
3 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 6 years ago

Hi Rick.
I’ve searched for that issue for a while and only found people with the same problem and without any answer.
The only thing I found was this library for Arduino: 
https://github.com/greiman/SdFat and this example: https://github.com/greiman/SdFat/blob/master/examples/Timestamp/Timestamp.ino
I don’t know if it works with the ESP8266. I think this is what you are already using in your code, right?
Regards,
Sara

0 Vote Up Vote Down
Rick Lutz answered 6 years ago

Yes on the SdFat or some version of it. I kept adding libraries until it got an error that was something like “not compatible with esp-8266” or close to those words.
 I will look at timestamp. 

0 Vote Up Vote Down
Sara Santos Staff answered 6 years ago

Hi Rick.
If you figure out something, please share with us.
That’s probably a subject that many people are searching for.
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.