If you like StringEEPROM Library... buy me a beer
A library for efficiently storing and managing multiple strings in EEPROM memory for Arduino and ESP32 platforms.
- Store multiple strings in EEPROM with dynamic allocation
- Command interface through Serial for interactive use
- Configurable debug output
- Configurable maximum number of strings
- Memory efficient implementation using flash memory for strings
- Compatible with both Arduino and ESP32 platforms
- Open Arduino IDE
- Go to Tools > Manage Libraries...
- Search for "StringEEPROM"
- Click Install
- Download latest release as ZIP
- In Arduino IDE: Sketch > Include Library > Add .ZIP Library
- Select downloaded ZIP file
- Restart Arduino IDE
The library uses the following format to store strings in EEPROM:
[len1][data1][len2][data2]...[255]
where:
len
= length byte (0-254)data
= string content255
= terminator marking the end of all data
StringEEPROM()
Creates a new StringEEPROM instance with debug disabled and no limit on number of strings.
void setDebug(bool enable)
Enable or disable debug messages over Serial.
bool isDebugEnabled() const
Returns current debug status.
void setMaxStrings(int max)
Set maximum number of strings that can be stored. Use -1 for unlimited (default).
int getMaxStrings() const
Get current maximum strings limit.
void begin(uint32_t baudRate = 115200)
Initialize the library and Serial communication.
baudRate
: Optional baud rate for Serial (default 115200)
bool writeString(uint8_t n, const char* data)
Write a string to the specified position.
n
: Position (1-based index)data
: String to write- Returns: true if successful, false otherwise
int readString(uint8_t n, char* buffer, int maxLength)
Read a string from the specified position.
n
: Position to read (1-based index)buffer
: Buffer to store the stringmaxLength
: Maximum length of the buffer- Returns: Length of string or -1 if not found
int check()
Check EEPROM content validity.
- Returns: Number of strings stored, or -1 if EEPROM content is invalid
void init()
Initialize EEPROM by writing terminator at start.
void debugPrint(const __FlashStringHelper* message)
void debugPrintln(const __FlashStringHelper* message)
Print debug message from flash memory, with or without newline.
void debugPrintValue(const __FlashStringHelper* message, int value)
void debugPrintlnValue(const __FlashStringHelper* message, int value)
Print debug message with integer value, with or without newline.
void debugPrintChar(const char* message)
void debugPrintlnChar(const char* message)
Print debug message from RAM, with or without newline.
void handleSerial()
Process Serial commands. Should be called in loop().
void showAllStrings()
Display all stored strings with their positions.
void printHelp()
Display available Serial commands.
The library provides an interactive interface through Serial with the following commands:
N=string
- Write "string" at position N (e.g., "1=Hello")?
- Show all strings#
- Show number of strings!
- Initialize EEPROM (requires confirmation)h
- Show help message
Basic usage:
#include <StringEEPROM.h>
StringEEPROM eeprom;
void setup() {
// Optional: set maximum number of strings
eeprom.setMaxStrings(10);
// Optional: enable debug messages
eeprom.setDebug(true);
// Initialize with default baud rate (115200)
eeprom.begin();
}
void loop() {
// Handle Serial commands
eeprom.handleSerial();
}
- Each string requires length + 1 bytes of EEPROM space (length byte + string content)
- The library uses flash memory for constant strings to save RAM
- Maximum string length is 254 bytes due to length byte limitations
- EEPROM space is used efficiently with dynamic allocation
- Maximum string length is 254 bytes
- String positions are 1-based
- String content cannot contain byte value 255 (used as terminator)
- ESP32 virtual EEPROM requires commit() after changes
- AVR architecture
- ESP32 virtual EEPROM
- Generic Arduino
- Memory abstraction
- Platform-specific optimizations
- Fork repository
- Create feature branch
- Submit pull request
- GitHub Issues: Technical issues, bugs
- GitHub Discussions: Questions, ideas
- Email: [email protected]
MIT License - See LICENSE file
- Bug fix
- Initial release
- Basic string storage
- Serial interface
- Debug system
- ESP32 support