Adafruit SD Data Logging shield for Arduino

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
ServiceXp
 
Posts: 15
Joined: Tue Oct 14, 2014 9:54 am

Adafruit SD Data Logging shield for Arduino

Post by ServiceXp »

I purchased 2 of these shields, and they look good, well thought out design.

I having 2 problems:

1) The documented sketch fails to open the created .csv file. It creates the file, but it looks like it can't open it. If I change the file type to .txt everything works fine, and I no longer get the "couldn't create file" error.

2) When the file is created, it's created / modification date is set to something like 01-01-2010. How do I get the modify date set?

This version does not work:

Code: Select all

 // create a new file
char filename[] = "LOGGER00.CSV";
for (uint8_t i = 0; i < 100; i++) {
filename[6] = i/10 + '0';
filename[7] = i%10 + '0';
if (! SD.exists(filename)) {
// only open a new file if it doesn't exist
logfile = SD.open(filename, FILE_WRITE);
break; // leave the loop!
}
}
if (! logfile) {
error("couldnt create file");
}
This version works perfectly:

Code: Select all

 // create a new file
char filename[] = "LOGGER00.TXT";
for (uint8_t i = 0; i < 100; i++) {
filename[6] = i/10 + '0';
filename[7] = i%10 + '0';
if (! SD.exists(filename)) {
// only open a new file if it doesn't exist
logfile = SD.open(filename, FILE_WRITE);
break; // leave the loop!
}
}
if (! logfile) {
error("couldnt create file");
}

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Adafruit SD Data Logging shield for Arduino

Post by adafruit_support_rick »

Easy answer first: The library does not support time stamping files. You can't get the creation/modification date set.

Hard answer: I have no explanation. The library doesn't know anything about particular extensions. .CSV should work just as well as .TXT.

User avatar
ServiceXp
 
Posts: 15
Joined: Tue Oct 14, 2014 9:54 am

Re: Adafruit SD Data Logging shield for Arduino

Post by ServiceXp »

adafruit_support_rick wrote:Easy answer first: The library does not support time stamping files. You can't get the creation/modification date set.

Hard answer: I have no explanation. The library doesn't know anything about particular extensions. .CSV should work just as well as .TXT.

I know it's very strange. It simply will not work with the CSV ext. Any other good/easy spreadsheet ext's I can try?

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Adafruit SD Data Logging shield for Arduino

Post by adafruit_support_rick »

There's something else going on. I just ran the GPS logger sketch with a CSV extension and it worked fine.

Can you post your entire sketch?

User avatar
Franklin97355
 
Posts: 23939
Joined: Mon Apr 21, 2008 2:33 pm

Re: Adafruit SD Data Logging shield for Arduino

Post by Franklin97355 »

Check this out for info on time stamping.

User avatar
ServiceXp
 
Posts: 15
Joined: Tue Oct 14, 2014 9:54 am

Re: Adafruit SD Data Logging shield for Arduino

Post by ServiceXp »

adafruit_support_rick wrote:There's something else going on. I just ran the GPS logger sketch with a CSV extension and it worked fine.

Can you post your entire sketch?
Sorry for the delay... You were right, while testing I also ran into the same problem with the .txt ext. I started breaking down my sketch and decided to change the setup order of a few functions and I discovered that if I initialize my DHT sensors before initializing the SD Card I would run into this problem.

Very strange.

User avatar
ServiceXp
 
Posts: 15
Joined: Tue Oct 14, 2014 9:54 am

Re: Adafruit SD Data Logging shield for Arduino

Post by ServiceXp »

franklin97355 wrote:Check this out for info on time stamping.
I don't understand? I didn't see anything referencing the file date created and modified stamps in that information???

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Adafruit SD Data Logging shield for Arduino

Post by adafruit_support_rick »

Glad to hear you found the issue. Not sure why that would cause the problem, but if it works... :)

The SDFat library supports file creation timestamps - not sure about modification date, but I assume it does that as well.

https://github.com/greiman/SdFat

User avatar
ServiceXp
 
Posts: 15
Joined: Tue Oct 14, 2014 9:54 am

Re: Adafruit SD Data Logging shield for Arduino

Post by ServiceXp »

Thank You

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino Shields from Adafruit”