Large size of data to save

Hey guys,
I would like to save the results from mpu6050 and two proximity sensors (20Hz) on the sd card using arduino. The first problem is I cannot timestamp each line of results with RTC in milliseconds. another is that the number of data per second is reduced from about 22 to 6 after one hour writing data on the sd card.

has anyone any solution for my problems?

MPU.ino (14.4 KB)

ebarash:
The first problem is I cannot timestamp each line of results with RTC in milliseconds.

Why not?

pert:
Why not?

Because RTC DS1307 doesn’t support the accuracy of millisecond

Emit the time and current millis at the beginning of your program.
On each data row, just emit millis and post process it by whatever means to calculate the timestamp.

As to speed of saving data, don't open and close the file on every iteration of loop.

wildbill:
Emit the time and current millis at the beginning of your program.
On each data row, just emit millis and post process it by whatever means to calculate the timestamp.

As to speed of saving data, don’t open and close the file on every iteration of loop.

So you mean there is no need to open and close the file each time to write new data?

ebarash:
So you mean there is no need to open and close the file each time to write new data?

Correct, open it once, close it once.