Large buffer for temporary data storage

Hi All,

I develop a system on Arduino MKR 1010 to read the sensor data from analog pots and stream them to a server when wifi is available. If wifi is not available, the data will be temporarily saved in an array until the system reconnects to the wifi.
However, this approach has two drawbacks: the array takes a huge amount of the dynamic memory and they will be lost if power off before wifi reconnection.
Since MKR does not have an EEPROM, I am trying to use the SD card as a buffer. I can keep writing the data to a file use SD. write, but the question is: how can I read certain bytes from a file and then delete after read?
Or are there any methods to develop a large buffer in Arduino for data storage? It does not necessary to be FIFO or LIFO, what I want is just to record all data steam them to the server after wifi reconnection.
Any comments or ideas are welcome. Thanks in advance.

Hello
take a internet search engine and ask the world wide net to look for FRAM shield

You could use the seek() function to move the file cursor to the required record if the data is structured and you know which record number you want to access

You cannot expressly delete a record unless you copy all records before and after the selected one to a new file but you could mark it as not valid by writing a specific value to it that you would recognise later. This would make the file grow larger as records are added so you could consider reading the file and copying all valid records to another file periodically

1 Like

That sounds to be a good solution. I can use two pointers to indicate the start and the end of the buffer in the file. Thanks a lot.

Have look at my project on Datalogging to SD card

Your project is quite similar to mine :slightly_smiling_face:, I save the data locally but I also do some on-board processing and send significant data to the server (e.g. when detecting abnormal signals).
When sampling the signals and recording them at the same time, how do you work with the multi-tasking so that the recording task does not block the signal sampling if it takes a long time to write the SD?

There are sets of buffers. One is filled by interrupt from the ADC while the other is written to the SD.
There are checks for missed interrupts and buffer overruns (ie. dropped data) in the code.
The teensy board is much faster, but Uno/Mega still works

1 Like

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.