EEPROM Library for Arduino
Written by: Christopher Andrews.
What is the EEPROM library?
The EEPROM library provides an easy to use interface to interact with the internal non-volatile storage found on AVR based Arduino boards. The library uses a set of native C++ classes which allows for very efficient usage by preventing any unnecessary overhead from being added to a sketch. This library will work on many AVR devices containing an EEPROM, such as ATtiny and ATmega chips.
Purpose of this thread:
The EEPROM library has been rebuilt from the ground up. It has an improved set of basic functionality helping to make entry level use easier. As a consequence of its own design, it includes an advanced API for all the seasoned and tasty programmers out there.
This thread is intended for discussion as well as support. If you have a question on how to use the EEPROM library in your project, fire away. Once the discussion is over, hopefully this thread can become a one stop shop for EEPROM help and various examples. Don't hold back if you would like to discuss some aspect of the library/documentation, or simply let me know what you think. Also if you create an example sketch you feel highlights a useful feature, or solution to a common problem: post it and it can be linked from this index, or even proposed as an addition to the IDE.
The site reference has just been updated with the basic set of functionality (after writing this article). However this documentation will eventually contain all the reference material from basic to advanced usage. And to allow for the best documentation possible, we can take the time here to improve on it before adding it to the official resource if warranted. Or simply have an in-depth resource here. Once I'm happy with the next sections, I'll update these posts.
A quick overview:
The basic functionality for the library now consists of seven functions.
EEPROM.read( address )
EEPROM.write( address, value )
EEPROM.update( address, value )
EEPROM.get( address, object )
EEPROM.put( address, object )
Subscript: EEPROM[ address ]
EEPROM.length()
For IDE versions prior to 1.6.2, only the
** **.read()** **
and
** **.write()** **
members are available.
Whats next?
I already have an update currently on the test bench containing a few improvements. I decided to leave these separate as they need in-depth testing and I want to consult the community as there may be additions I haven't considered yet. The two main features the next update includes are below. These additions do not impact the performance of the class, but more so, the library will encapsulate every feature found in all custom EEPROM libraries (and more).
- Modification allowing
- ```*
- .get()*
-
```*
and - ```*
- .put()*
-
```*
to accept arrays, not just objects. - Addition of
- ```*
- .readBit()*
-
```*
and - ```*
- .writeBit()*
-
```*
functions to EEPROM class.
Also, any interest in some EEPROM versions of the standard memory functions like
** **strlen_E** **
,
** **strcpy_E** **
,
** **memset_E** **
,... similar to what is provided for PROGMEM (
** **memcpy_P** **
).
Conclusion
As a member of the forums for over three years, I can see the value regular members place on being kept up to date with what is happening in the Arduino project. So as the author of this library I feel it necessary to provide support for my code, as well as collaborating with the actual users of the library to help create a great end result.
Cheers.