I am developing a wearable which connects to a mobile app over BLE. Data is sent every 10 seconds and includes a timestamp, a step value, and a heart rate and other data (total of 32 bytes).
I am looking to find a way to store this data on the board when not connected to a mobile device. What is the best way of doing this? Should I store the data in the MCU internal flash?
32 bytes every 10 seconds is 192 bytes per minute. 6 minutes of this will fill the Arduino UNO's EEPROM memory.
On the SAM D21 (Arduino Zero) the EEPROM library will allow you to use up to 16KB of the flash memory as if it was an EEPROM. That gives you 85 minutes of logging. Maybe if you cut down the logging rate in this mode? Maybe store a summary every 2 minutes, then you can stretch it out to many hours. I highly recommend using the EEPROM library to start with as it will insulate you from all of the weird things required by the flash memory.
You are right on the corner of several different technologies. Most people trying to log data on an Arduino are using much more memory and then the solution is obvious: use an SD card. The SD card is easy to use for moderate amounts of data (not megabytes per second) and easy to pop out and feed into a full-size PC for analysis.
For a mobile device, you do worry a little about the SD card remaining secure in its slot. If it has to endure impacts while logging data then a hard-soldered FRAM chip is desirable. But in every other case the convenience and simplicity of the SD card are winners.
ddesousa:
I forgot to mention, in this mode, I am only writing data every minute.
Unfortunately, due to PCB space, I am unable to use a SD card. However, I do like your idea about using the EEPROM library.
Using processor Flash memory as EEPROM might seem attractive, but Flash memory tends to have a very limited write life, say 10,000 writes, so at one write a minute you could wear it out in 7 days.
A FRAM is a very good idea.
A Fujitsu 2k byte FRAM costing around £1, has a write endurance of 10,000,000,000 times.
The Cypress FRAMs of the same size and cost claim a write endurance of 100,000,000,000,000 times.
I have seen EEPROM or falsh (emulated EEPROM) burned out after a few weeks when project specifications were change from updateding every few months to evey few minutes. I would use FRAM which also has the advantage of retaining informaton after power loss
Look at Adafruit's Itsybitsy M0 Express SAMD21 breakout board. It's got a 2MB flash chip in addition to the 256K/32K onboard flash/ram. I'm using it to hold arrays of light intensity data in a light meter application.