1

Updated question to be less vague.

I plan to log sensor data by time so something like sqlite would be perfect, but it requires too much resources in something like an atmega328p. Most of the searching will be done off the uC.

What do other people use? Flat text files? XML? A more complicated data structure?


Thanks for the feedback. It is good to know what other people are using. I've decided to serialize my data structures and save them in a binary file to eliminate string processing on the uC for now.

Nabil
  • 343
  • 3
  • 8

2 Answers2

2

I've used flat text files for similar projects, albiet years ago, but I believe it's still a good approach for that environment. Since you don't need to process the data on-chip, you want it to be as efficient as possible (as little overhead as possible).

However, if you want more flexibility and weren't as concerned about space, perhaps saving JSON objects would be better, where each field is identified clearly. A tiny bit of overhead for creating the objects, but allows you to add and remove fields without complex logic on the interpreting side. I would pick JSON over XML just because you have about half the overhead (in space, and probably in processing).

Doug Kress
  • 3,537
  • 1
  • 13
  • 19
1

With a small micro-controller like the 328, it is very important to determine the space requirements.

How big is each record? How many records do you want to store? How will you get the records off of the micro-controller?

Like Doug, I usually use a flat text to store data. So each record might contain year, day of the year and a value if I am storing a value once a day.

The file would look like:

11,314,100<cr>
11,315,99<cr>
11,316,98<cr>
11,317,220<cr>

You could store approximately 90-100 records, requiring you to dump the data every three months

If you need more then the 1kEEprom holds (200 5 byte records, 100 10 byte records or simliar) then you will need additional memory using an IC, SD or Flash.

If you want to unplug the memory and plug it into a PC, then the SD or Flash would be best.

You could use a vinculum chip from FTDIChip.com to simplify writing the fat files to flash drive.

Jeff
  • 1,364
  • 1
  • 8
  • 17