Interfacing External EEPROM Arduino

 📖 1. Introduction

Standard Arduino projects lose their data (like registered RFID cards) once the power is disconnected. By interfacing an AT24C256 External EEPROM, we can store up to 256 Kbits (32,768 bytes)  of data. This is essential for professional attendance systems, security locks, and data loggers where data must be permanent.


🔧 2. Components

  • Arduino UNO
  • AT24C256 EEPROM Chip
  • Two $4.7\text{ k}\Omega$ Resistors (I2C Pull-ups)
  • Breadboard and Jumpers


🔌 3. Circuit and Connections

Arduino Uno Pinout Diagram
Pinout Diagram of Arduino Uno

AT24C256 module Pinout Diagram
AT24C256 module Pinout diagram

The AT24C256 uses the I2C Protocol, requiring only two data wires (SDA and SCL).

AT24C256 PinArduino PinNotes
VCC5VPower Supply
GNDGNDGround
SDAA4Serial Data (use 4.7 k pull-up)
SCLA5Serial Clock (use 4.7 k pull-up)
WPGNDWrite Protect (Connect to GND to enable Writing)
A0, A1, A2GNDSets I2C Address to 0x50

Address Table for AT24C256 if Multiple Chips Present

A2

A1

A0

I2C Hex Address

GND

GND

GND

0x50 (Your current setup)

GND

GND

5V

0x51

GND

5V

GND

0x52

5V

5V

5V

0x57


⚙️ 4. Step by Step Circuit Working

  • I2C Communication: Arduino acts as the Master and the EEPROM as the Slave.

  • Addressing: The Arduino sends the chip's address (0x50) followed by the specific memory location.

  • Data Storage: Unlike RAM, the EEPROM holds this data even after the power is switched off.

  • Write Cycle: It takes about 5 ms for the chip to physically save a byte.


💻 5. Code

This sketch writes a test value to address 0 and reads it back to confirm storage.

C++
#include <Wire.h>

#define EEPROM_ADR 0x50 // Standard I2C address

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

  int address = 0;
  byte dataToWrite = 123;

  // 1. Write Data
  writeEEPROM(address, dataToWrite);
  Serial.println("Data Written successfully!");

  delay(10); // Wait for write cycle

  // 2. Read Data
  byte value = readEEPROM(address);
  Serial.print("Data Read from EEPROM: ");
  Serial.println(value);
}

void loop() {
  // Empty loop
}

void writeEEPROM(int addr, byte data) {
  Wire.beginTransmission(EEPROM_ADR);
  Wire.write((int)(addr >> 8));   // MSB
  Wire.write((int)(addr & 0xFF)); // LSB
  Wire.write(data);
  Wire.endTransmission();
  delay(5); 
}

byte readEEPROM(int addr) {
  byte rData = 0xFF;
  Wire.beginTransmission(EEPROM_ADR);
  Wire.write((int)(addr >> 8));   
  Wire.write((int)(addr & 0xFF)); 
  Wire.endTransmission();
  
  Wire.requestFrom(EEPROM_ADR, 1);
  if (Wire.available()) rData = Wire.read();
  return rData;
}

🔍 6. Step by Step Code Working

  • Wire.beginTransmission: Starts talking to the EEPROM at address 0x50.

  • Address Shifting: Since the EEPROM has many memory slots, we send the address in two parts (High byte and Low byte).

  • Write Time: A small delay is added because writing to hardware memory is slower than reading.

  • Wire.requestFrom: The Arduino asks the EEPROM to send back the data stored at that specific location.


💡 7. Tips

Pull-up Resistors: Always use resistors on SDA/SCL lines for stable communication.

I2C Address: If you connect A0, A1, or A2 to 5V, the address will change. Use an I2C Scanner to be sure.

Write Endurance: Avoid writing to the same address thousands of times in a loop, as it can wear out the memory.


🚀 8. Uses

  • Attendance Systems: Permanently storing RFID card UIDs.

  • Settings: Saving user passwords or brightness settings.

  • Data Loggers: Storing sensor data like temperature or humidity.


⚠️ 9. Common Issues and Solutions

Data not saving

✔ Check the WP (Write Protect) pin. It must be at GND. If it is at 5V, writing is blocked.

I2C Error

✔ Ensure wires are tight and you are using pins A4 (SDA) and A5 (SCL) on the Arduino Uno.


🧠 10. Conclusion

Using an external EEPROM is the best way to upgrade your Arduino projects to a professional level. It ensures your data is safe even during power failures, making it the perfect companion for ay projects that need data storage.

തുടക്കക്കാർക്കായി ഇലക്ട്രോണിക്സ് ലളിതമായി പഠിക്കാം.

Empowering students in Kerala with hands-on technical skills.