Reading 12 rows of data from a SDcard every mint and storing the data into Array

Hi,

I am working on a project that measures temperature and current, store it on an SD card (csv file) and send them to a website. I decided to sample the signals every 5 seconds and store the data to the SD card using time interrupt (TimerOne). My plan is to sample and store data for 1 minute and then read the sampled data from the SD card and store them into 2 Arrays i.e Array1 for temperature and Array2 for the current and send the data to the website.

Thus far I have managed to sample and store the data using the time interrupt. I also included a count variable in the interrupt subroutine so as to know how many times the interrupt has occurred. Since I am sampling and storing the data every 5 seconds and I want to read the data stored in the SD card every minute, so when count = 12 I would like to read the last 12 readings (24 since its current and temperature ) and store them into 2 Arrays. The problem I have is that I do not know how to read the data from the SD card and store them into two Arrays and would like your help.
Note: the Reading of the SD card will not be in the Interrupt subroutine

the data is stored into two column per row in the csv file. e,g

24.3,10
30,14
27.5,1.3

and so on.

Any help or suggestions will be highly appreciated.

Thanks

Muundu.

A couple of comments.

Do you really need to use an interrupt for the 5 seconds timer ? Could you not do it just as simply using millis() ?
It would be easier to read the data back into 2 arrays if there was one item of data on each line.
Do you actually need the data stored on the SD card ?
How about turning the requirement on its head and saving the data to the arrays every 5 seconds and writing it to the website and the SD card every minute ?
How long will it take to send the data to the website and could that take longer than 5 seconds ?
Would a timestamp of when the data was acquired or saved be useful ?

Hi UKHeliBob,

Thanks for the response.

Yes i do need the SD card since the project requirement is for me to have an onsite storage (SD card) and a website for offsite viewing.The reason as to why i decided to use the timer 1 interrupt is that it took between 12 to 15 seconds for me to upload data to my website and i do not want to lose data when the board is sending the Data via GPRS hence i thought of the interrupt and after 1 minute i can read the data in the SD card into two Arrays and send it to the website.

Now i am thinking of having of storing the data into two files(File1 and File2) and after i have recorded 12 readings in each(After 1 minute) i can read the data in File2 into 2 arrays and then delete File2 in that way i can have File1 as the onsite storage file and i use File2 for reading only the 12(Logged data, 24 since its temperature and current).My problem is that i do not know how to read the data into two arrays or maybe i am looking at this the wrong way.

Eventually i will include a time-stamp using a real time clock but for now i am playing around with temperature and current. as for the board, i am using the Gboard pro(Red version) . It has an SD slot and the Sim900 gsm module.

Reading the data from the card is easy. There are examples in the SD library that show how.

Storing the data in a char array, and NULL terminating it, is not hard. Recognizing that you have reached the end of the line is not difficult. Parsing the data in the array is easy, using strtok(). Converting a token to a value is easy, using atof() or atoi() depending on whether you want a float or an int from the token.

Storing the values in arrays is not hard.

Try something, and if you have problems, let us know.