User’s Guide: AT24C256 EEPROM I2C Interface Storage Module
Overview
The AT24C256 is a 256-kilobit (32KB) serial EEPROM organized as 32,768 × 8 bits. It communicates via the I²C protocol and is ideal for storing configuration data, logs, or calibration tables in embedded systems.
- Interface: I²C (2-wire)
- Capacity: 32KB (256Kb)
- Voltage Range: 2.7V to 5.5V
- Write Cycle Time: ~5ms typical
- Page Size: 64 bytes
- Addressing: 15-bit memory addressing
Pinout Reference
Pin Label | Function | Notes |
---|---|---|
VCC | Power Supply | 2.7V–5.5V |
GND | Ground | Common ground |
SDA | Serial Data | Connect to MCU SDA |
SCL | Serial Clock | Connect to MCU SCL |
WP | Write Protect | Tie to GND to enable writes |
A0–A2 | Address Pins | Set I²C address (0x50–0x57) |
Wiring Example (ESP32 / Arduino)
AT24C256 → MCU
-----------------------------
VCC → 3.3V / 5V
GND → GND
SDA → GPIO21 (ESP32) / A4 (Arduino Uno)
SCL → GPIO22 (ESP32) / A5 (Arduino Uno)
WP → GND
A0–A2 → GND (default address: 0x50)
Use pull-up resistors (4.7kΩ–10kΩ) on SDA and SCL if not already present.
Initialization (Arduino Example)
#include <Wire.h>
#include <EEPROM_I2C.h> // Use a compatible library like "AT24C256"
#define EEPROM_ADDR 0x50
void setup() {
Wire.begin();
Serial.begin(115200);
EEPROM_I2C.begin(EEPROM_ADDR);
}
Writing Data
uint8_t data = 42;
EEPROM_I2C.writeByte(0x000A, data); // Write to address 0x000A
- Writes are page-buffered (64 bytes max per page)
- Avoid crossing page boundaries in bulk writes
Reading Data
uint8_t value = EEPROM_I2C.readByte(0x000A);
Serial.println(value);
Addressing Tips
- Full address range: 0x0000 to 0x7FFF
- For bulk writes, use:
EEPROM_I2C.writePage(startAddress, byteArray, length);
Write Protection
- Tie WP pin to VCC to disable all write operations
- Useful for firmware-safe zones or calibration constants
Troubleshooting
Symptom | Possible Cause | Fix |
---|---|---|
No response on I²C | Wrong address / wiring | Check A0–A2, SDA/SCL |
Data not saved | WP pin tied high | Tie WP to GND |
Corrupted reads | Page boundary violation | Align writes to 64-byte pages |
Slow performance | Excessive writes | Use buffered writes, delay reads |
Advanced Use
- Integrate with FreeRTOS tasks for logging
- Use CRC checks for data integrity
- Store structs or calibration tables with offset mapping