Skip to content

baaaaan1/EEPROMHandler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EEPROMHandler

English documentation. Indonesian version: README.id.md

EEPROMHandler is an Arduino-compatible I2C helper library for AT24Cxx external EEPROM chips. It provides typed save/read/validate helpers for int, long, float, double, char, bool, String, byte arrays, and int arrays.

Important (v2.x)

  • Chip configuration is now required before any read/write operation.
  • You must choose one configuration method:
    • setChipType(...)
    • setChipGroup(...)
  • If one mode is already selected, the other mode returns false.

Current Focus / Supported Use

  • Tested focus: AT24C128, AT24C256
  • Generic group configuration is available for:
    • AT24ChipGroup::Large2ByteAddress
    • AT24ChipGroup::Small1ByteAddress (custom capacity setup)

Installation

Install from Arduino Library Manager or copy this repository into your Arduino libraries folder:

Documents/Arduino/libraries/EEPROMHandler

Quick Start (Recommended: setChipType)

#include <Wire.h>
#include "EEPROMHandler.h"

EEPROMHandler eeprom(0x50);

void setup() {
    Serial.begin(115200);
    Wire.begin();

    if (!eeprom.setChipType(AT24ChipType::AT24C256)) {
        Serial.println("Chip config failed");
        return;
    }

    eeprom.saveInt(0, 1234);
    int value = eeprom.readInt(0);
    Serial.println(value);
}

void loop() {}

Alternative Setup (setChipGroup)

Example for AT24C256 (32 KB, 2-byte word address):

eeprom.setChipGroup(AT24ChipGroup::Large2ByteAddress, 32768);

API Notes

  • saveInt() / readInt() store 16-bit signed values (2 bytes) for cross-board consistency.
  • saveLong() / readLong() store 32-bit signed values (4 bytes).
  • double is stored using the board's native sizeof(double) (4 or 8 bytes depending on core).
  • String stores a 2-byte length header followed by raw characters.
  • All operations require successful chip configuration first.

Compatibility Notes

  • Library compile compatibility is broad (architectures=*), but behavior depends on Wire implementation and chip/addressing setup.
  • double data is not guaranteed cross-board compatible (e.g. AVR vs STM32/ESP) because size may differ.
  • For portable EEPROM layouts across boards, prefer int (16-bit stored), long (32-bit stored), float, and byte buffers.

Examples

The examples/ folder is split by difficulty and feature:

  • 01_Basic_SetChipType
  • 02_Basic_SetChipGroup
  • 03_PrimitiveTypes
  • 04_String_And_Bytes
  • 05_Array_And_Validation
  • 06_AddressMap_Layout
  • 07_ChipConfigRequired

File Structure

EEPROMHandler/
|-- examples/
|-- src/
|   |-- EEPROMHandler.h
|   `-- EEPROMHandler.cpp
|-- keywords.txt
|-- library.properties
|-- README.md
`-- README.id.md

License

This project is licensed under GPL-3.0.

About

Arduino I2C helper library for AT24Cxx EEPROM with typed read/write APIs and explicit chip configuration (setChipType / setChipGroup).

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages