This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Best way to save sensor data with FDS?

Hi,

I want to collect sensor-data, save it to flash and access it later. I´m not quite familiar with ways to save data and get a little bit confused by the fds library (but already managed to save and retrieve data).

Let`s say I want to save an int32 every minute. If i give each value a Record Key and a File ID am I right, that I have 12 byte of record header for every value?

My next Idea was to store the values in an array, and then save it. So I only get the header once per array. Is this the way to go? Are there any recommendations to the array size?

Or is there a way I can just add my data at the end of the already stored data under the same Record Key and File ID?

If I access my data I never need to access a specific part of it. I just need everything in the order it was saved, so I can send it to my android app, the rest is done there.

Thanks for your help :)

P.S.: I use SDK 13

  • FormerMember
    0 FormerMember

    Yes, saving all sensor data separately will give a lot of extra overhead. FDS has a function for updating a record, fds_record_update(). By using this function, you will avoid using a lot of extra overhead. However, this function will write all the data for each update, so the amount of extra writing will increase with the amount of sensor data.

    I would recommend you to do a middle way:

    1) Store multiple sensor data values in one record, using fds_record_update(). After a while, I would recommend you to continue storing data in new record, to avoid too much extra writing.

    or

    2) Put some sensor data values in an array before storing the values using fds. Each sensor data array can be put in a new record, or updating an old one. To make sure to not loose a lot of data in case of power loss, I would recommend you to find a trade-off between the amount of sensor data in the array and the required write operations for updating a record or amount of header for a new record.

  • Thanks for your answer I will do it the second way you mentioned.

Related