Some Arduino boards have a built-in EEPROM that can be written to and read from in your programs. I not only want to discuss how that’s possible but I also want to show you an alternative while talking about EEPROMs and memory in general.
But let’s start with the basics of memory and memory organization! If you’re here for the tutorial simply scroll down.
EEPROMs in general
EEPROM stands for Electrically Erasable Programmable Read-Only Memory and it’s a type of non-volatile memory that’s typically used to store a small amount of data in applications where quick access is not of utmost importance but which require random access.
Furthermore, EEPROMs usually allow accessing (read/write/delete) each word (usually a byte) stored in the memory unlike, for example, flash memory, which normally only allows accessing a whole block at once.
Unfortunately EEPROMs can only be deleted and re-programmed a limited number of times reaching anywhere from 100,000 to 1,000,000 operations before the chip breaks.
On the plus side, EEPROMs usually work in a large range of operating temperatures and can hold data for a very long time (sometimes even hundreds of years (At least that’s what manufacturers promise but who’ll be around to check?)).
Like mentioned above, each word can usually be directly addressed and accessed. The typical word length is 8-bit (one Byte). Multiple words are often grouped onto pages and many modern EEPROMs allow accessing an entire page at once (for performance reasons).
However, pages are not physically present. More than often enough it’s a simple limitation caused by a buffer size or a simple convention and usually the data in an EEPROM is organized in blocks.
An example: The EEPROM-IC displayed in fig. 1 (24LC16) is organized in 8 blocks with 256 words each. A word is 1 Byte long and a block can hold 16 pages with a size of 16 words. Therefore the memory is organized like this:
16.384 bits total storage space is divided into 8 blocks with 256*8 bits
where each block consists of 16 pages with a page size of 16 Byte (128 bits).
16.384 = 8 * 256 * 8 = 8 * 16 * 16 * 8
total = blocks * bytes_in_block * 8 = blocks * pages * bytes_in_page * 8
Arduino built-in memory and external EEPROMs
Now it’s time for the tutorial! I wrote an article on maker.pro in which I describe both methods in detail. The article contains a lot of source-code examples and also the full code for interfacing an external EEPROM IC.