Data Storage to SD Card with a few caveats

Hello,

Being new to the forums (but not Arduino!) I hope this is the right area for my questions...

I want to figure out a way for a few things to be logged on an SD card with either an UNO or Mega... Not sure which one yet, I have to see how many pins I need.

But anyhow, the goal is this:

1- User inputs a number from a matrix keypad (i.e. 1 or 11 or 12). Whole numbers only, and only positive numbers 1-99
2- Arduino reads sensor, depending on which button is pressed (let's call it Button 1), and logs that value in a .csv (i.e. 1,7.4)
3- User repeats step one
4- Here is where it gets interesting: If the user inputs 1, then presses Button 2, I want the arduino to revise the .csv entry for 1 to, say, 1,7.4,8.2

I do not want multiple entries in the .csv like:

1,7.5
1,8.2
1,9.0

Is this possible?

The application of this is that my project will require one sensor reading (like temperature) of 10 samples (each assigned a number 1-10). Then, the temp sensor is switched out for a different sensor and the same samples are read, but for a different variable. Eventually, an ideal .csv entry would be 1,x,y,z

So can I do this? I can figure out basic SD entry tasks, and I'll integrate an LCD and a few LED indicators. But the data logging comes first and foremost.

Any suggestions on how to approach this?

Many thanks,

Hi,

Rather than write the record to the SD each time the sensor is read, you could collate the values, then only write the record once when the next button is pressed. This would remove the need to revise the .csv. If you're talking about a maximum of 10 readings each time this could be as easy as populating an array of values and writing those values out when the next button is pressed.

Cheers ! Geoff

Hi

Rather than store the arrays sorted, my first thought would be to store them as they arrive but construct the csv record from the array values in ascending order at the time you write your record to SD.

I don't have a sketch as an example so please post your existing sketch here so we can give you some pointers on what you can do in your specific case. (remember to use the # button to enclose your sketch in CODE tags)

Does your sketch do what you outlined in the first post currently (ie multiple entries)? That will be a solid place to start.

Cheers! Geoff