Logger stops at 99 files. I would like it to go up to 100,000.

 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!
    }
  }

The datalogger doesn’t log past Logger 99. I have already tried changing “i<100” to “i<100000” :frowning: Please don’t ask me to post the whole sketch I am creating a prototype that I will present to a company next month and don’t want to give the farm away.

The filenames in your current scheme, "LOGGER00.CSV" to "LOGGER99.CSV", have 8 characters preceding the decimal.

Use them wisely.

PS: you might do some research on the limitations of the file system. Is it even possible to have 99999 entries in the filename table?

You may want to consult the documentation of the SD library to see the rules for filenames.

  char filename[] = "LO00000.CSV";
  for (uint32_t i = 0; i < 100000; i++)
  {
    filename[2] = ((i / 100000UL) % 10) + '0';
    filename[3] = ((i / 10000) % 10) + '0';
    filename[4] = ((i / 1000) % 10) + '0';
    filename[5] = ((i / 100) % 10) + '0';
    filename[6] = ((i / 10) % 10) + '0';
    filename[7] = (i % 10) + '0';

After the first few thousand files it’s going to take a long time to find the next available filename.

Note: The FAT16 file system can only have 512 files/folders in the root directory. Is there a FAT32 library for the Arduino?

Quikksilver: Please don't ask me to post the whole sketch I am creating a prototype that I will present to a company next month and don't want to give the farm away.

Please don't ask the hobby forum open-source community fir free engineering help on your for profit venture unless you plan to return here to share the profits.

What you are doing is like keeping costs low at your restaurant by getting your soup from the free soup kitchen and your bread from the free bread line and then selling it. It's despicable.

If it is for a company and can't be shared then hire an engineer and make him sign an NDA. Don't be one of those low lifes who run so many good engineers out of work by cheaping out and trying to get it done for free.

Inquiring minds want to know what kind of soup and bread is being served?

No soup for you.

:'(

|500x268

johnwasser:

  char filename[] = "LO00000.CSV";

for (uint32_t i = 0; i < 100000; i++)
  {
    filename[2] = ((i / 100000UL) % 10) + ‘0’;
    filename[3] = ((i / 10000) % 10) + ‘0’;
    filename[4] = ((i / 1000) % 10) + ‘0’;
    filename[5] = ((i / 100) % 10) + ‘0’;
    filename[6] = ((i / 10) % 10) + ‘0’;
    filename[7] = (i % 10) + ‘0’;





After the first few thousand files it's going to take a long time to find the next available filename.

Note: The FAT16 file system can only have 512 files/folders in the root directory. Is there a FAT32 library for the Arduino?

thank you @ johnwasser for showing me how the for loop worked and by that extension what I need to do to manipulate the code to do what I want.

Delta_G:
Please don’t ask the hobby forum open-source community fir free engineering help on your for profit venture unless you plan to return here to share the profits.

What you are doing is like keeping costs low at your restaurant by getting your soup from the free soup kitchen and your bread from the free bread line and then selling it. It’s despicable.

If it is for a company and can’t be shared then hire an engineer and make him sign an NDA. Don’t be one of those low lifes who run so many good engineers out of work by cheaping out and trying to get it done for free.

I am not a private company. I am actually an aspiring electrical engineer that is about to graduate. I didn’t realize that the arrays must be manipulated as well. A company has shown interest in my project and I will be presenting a go to market strategy within a months time to them. I have programmed everything else in my project just needed a little help from the forum. I have also paid for most everything myself on a part time students budget. Instead what I get this bs sent to like I’m some sort of unethical shark preying on hobbyists. People like you are the reason so many don’t use the forum and stay in the dark. Today I learned something no thanks to you.

Today I learned something no thanks to you.

OK, we take back johnwasser's gift that "solved" your code problem. Except that using it will violate the file system restrictions.

Come back again!

jremington:
OK, we take back johnwasser’s gift that “solved” your code problem. Except that using it will violate the file system restrictions.

Come back again!

Besides which, johnwasser’s code has a serious bug in it, in the part which inserts the digits into the filename.

Quikksilver:

 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!
    }
  }




The datalogger doesn't log past Logger 99. I have already tried changing "i<100" to "i<100000" :( Please don't ask me to post the whole sketch I am creating a prototype that I will present to a company next month and don't want to give the farm away.

From where did you copy that snippet? Did you even try to understand how it works?
What did you expect would be the next filename after LOGGER99.CSV ?

Or - OP could create a tree of folders with - say - 100 files per folder.

Then \1\1\3\65.dat... would be obviously 11365.dat

odometer: Besides which, johnwasser's code has a serious bug in it, in the part which inserts the digits into the filename. From where did you copy that snippet? Did you even try to understand how it works? What did you expect would be the next filename after LOGGER99.CSV ?

Just a guess. https://learn.adafruit.com/adafruit-data-logger-shield/using-the-real-time-clock-3

Hopefully we saved the OP from some embarrassment.

The demonstration could have been quite a flop, attempting to have an Arduino open 100,000 files. Time for a long coffee break.

Quikksilver: thank you @ johnwasser for showing me how the for loop worked and by that extension what I need to do to manipulate the code to do what I want. I am not a private company. I am actually an aspiring electrical engineer that is about to graduate. I didn't realize that the arrays must be manipulated as well. A company has shown interest in my project and I will be presenting a go to market strategy within a months time to them. I have programmed everything else in my project just needed a little help from the forum. I have also paid for most everything myself on a part time students budget. Instead what I get this bs sent to like I'm some sort of unethical shark preying on hobbyists. People like you are the reason so many don't use the forum and stay in the dark. Today I learned something no thanks to you.

So you’re trying to pass your job interview and convince people that you know what you’re doing by turning in our work? If you can’t handle this novice situation then that may be something your prospective employer should know before they hire you.

This is an open source community. That means we share code. If you don’t want to share then this isn’t an appropriate place for you.

I have decided to let the arduino count up to 10,000 files and decrease my sampling rate and leave it on over night to see if will go that high. The data logger is just for maintenance on my system to see when valid data was collected last. I have been completely alone on my project even though I have two other group member who don't like to do anything or have little knowledge and skills on programming. Some people need help from time to time, and thats what the internet is for. I hope that some people would understand that I don't want to give away everything and just needed help understanding a snippet. Some people like to irritate and stir the pot more than they like to help. To the people that tried to help thank you very much. To the people that only criticized and tried to get me angry. I can't control what you do, and you have your own opinion. :)

I'm not trying to do well on an interview. A company is interest in the Intelligent Irrigation System I have been working on for the last 6 months. If i get help on one little part I don't really see what the big deal. I'm not blatantly ripping off all the code from everyone. To much energy expelled on this post today goodbye to all

You need itoa(). https://www.nongnu.org/avr-libc/user-manual/group__avr__stdlib.html#gaa571de9e773dde59b0550a5ca4bd2f00.

even though I have two other group member who don't like to do anything or have little knowledge and skills on programming.

TRIFECTA !

PaulMurrayCbr:
You need itoa().

snprintf is also a good choice.