will be read-only starting December 31st, 2018. For more info please look at this Forum Post

Arduino erom (EEPROM) library

The erom library was made to ease programmers life and increasing development speed. It does so by providing the following features:

  • Easy way of reading, writing and updating any types of data (basic, structs, strings and arrays).
  • Update functions. The functions are similar to write functions, but update changed bytes only.
  • Data storage address management functionality, which will eliminate data space range allocation conflicts and take away the burden of knowing where each variable should be stored in EEPROM.
  • Multiple virtual storage areas, giving flexibility in data structure management.
  • Allowing to group all EEROM data related variables as a single entity, able to manage them all as one.
  • Data storage auto-verification system, which include application (sketch) id and version number control. So, when you flash a new version or a different application on your micro-controller, you won't have to worry about getting wrong/corrupt data.

The library can be found on github:

Basic usage

While the erom library provides complex data structure manipulations, it leaves access to basic/primitive way of use.

Direct access

long data;
erom::access.read_block(0, data);

This code will read a long (4 bytes) form address '0' into the 'data' variable.

A more convenient way of reading

// Bind unsigned long varibale 'data' to EEPROM address '32'
erom::Entry<unsigned long> data(32); // Auto-reads data from EEPROM
data = millis();  // Assing some value to RAM variable;      // Store RAM variable onto EEPROM

Letting erom to do your address space management

erom::Storage storage;

erom::Entry<char> data1 = storage.issue<char>();   // Allocate 1 byte
erom::Entry<int> data2 = storage.issue<int>();     // Allocate 2 more bytes
erom::Entry<float> data3 = storage.issue<float>(); // Allocate 4 more bytes


Advanced usage

To increase code readability and to ease data handling, erom library provides the tools to organize your EEPROM related data. Class Storage is made to provide easy memory space allocation management and batch operations with your variables.

First, we need to define the rules of loading and saving our data:

class Storage : public erom::Storage {
  // Storage data/variables definitions
  erom::Entry<float> volume;
  erom::Entry<short> brightness;

  // Binding variables to EEPROM memory addresses
  Storage() { issue(volume); issue(brightness); }

  // Define rules for loading storage into RAM
  virtual void OnLoad() { volume.load(); brightness.load(); }
  // Define rules for saving storage into EEPROM
  virtual void OnSave() {;; }

Once that is done, we can create an actual object, that will handle our EEPROM data operations for us.

Storage storage;

Finally, we can use our data as a single entity with variables indicating specific parts of it:

// Load EEPROM storage data into RAM

// Print loaded data
Serial.print("Original volume: ");
Serial.print("Original brightness: ");

Making changes to our data and storing it on EEPROM is as simple, as:

// Assign storage data new values (in RAM)
storage.volume = analogRead(A0) / 1024.f;
storage.brightness = map(analogRead(A1), 0, 1024, 0, 255);

// Store new data to EEPROM;

Full working sketch can be found here

More examples are provided with the library on github.