Search code examples
bytestoragearduinoeeprom

Number of records in 32 kilobytes?


I am considering buying an external EEPROM storage module for my microcontroller. However, it only has 32 kilobytes storage capacity.

I'm using this to store records where each record is basically 4 separate numbers ranging between 0 - 180.

How many records do you think 32 kilobytes could handle?


Solution

  • A single record is an element out of a range of 181^4 possible elements, giving an information entropy of log(181^4)/log(2) = 29.999 bits. So you can, with some effort, encode one element in 30 bits.

    This means you have floor(32 * 1024 * 8 / 30) = 8738 elements you can store. If you choose to encode using 32 bits - 4 bytes - for a significant simplification in your encoding logic, then it's 32 * 1024 * 8 / 32 = 8192 elements.

    This analysis does not count any additional overhead for metadata such as validity bits, or flags to indicate which element is the newest, etc.