TK31I2Cbeginner

EEPROM Memory

Bytes that survive a power cut, over I2C. Where settings go when there is no SD card — and the chip that teaches you writes are not free.

Comes in this kit — not sold separately

Specifications

TypeI2C EEPROM
InterfaceI2C, address 0x50 by default
EnduranceAbout 1,000,000 writes per cell
RetentionDecades
Supply voltage3.3 V or 5 V

What it is

Non-volatile memory on two wires. Write a byte, pull the power, come back and it is still there.

The number that matters is endurance: around a million writes per cell, which sounds infinite until you write in a loop. A sketch that saves a sensor reading to the same address every 100 ms burns through a million writes in a day. The fix is to write only when the value has actually changed, or to rotate through addresses so the wear spreads out.

Writes are also slow — about 5 ms each — and the chip ignores you while it is busy. Libraries handle the wait; hand-rolled code that writes in a tight loop silently drops most of it.

Compare with the ESP32's own flash, which is larger and needs no extra part. This is for boards that have no usable non-volatile storage, and for keeping settings somewhere that survives reflashing the firmware.

EEPROM Memory — front
Front
EEPROM Memory — back
Back
EEPROM Memory — side
Side

Pinout

  • GND (negative): Like the negative terminal (-) of a battery, connect to the control board's GND
  • VCC (positive): Like the positive terminal (+) of a battery, connect to the control board's 3.3V or 5V (this module supports both 3.3V and 5V)
  • SDA (data line): I2C data line, connect to the control board's SDA pin (Arduino Uno A4 or Pico GPIO 0)
  • SCL (clock line): I2C clock line, connect to the control board's SCL pin (Arduino Uno A5 or Pico GPIO 1)

Wiring

EEPROM Memory wiring

  1. GND → Control board GND
  2. VCC → Control board 3.3V or 5V
  3. SDA → Control board SDA pin
  4. SCL → Control board SCL pin

Example

// Note: This program requires the Wire library (included with Arduino)
// Arduino Uno R3 I2C pins are fixed: SDA=A4, SCL=A5
#include <Wire.h>  // I2C communication library

// EEPROM address (usually 0x50)
#define EEPROM_ADDR 0x50

void setup() {
  // Start I2C communication
  Wire.begin();
  
  // Start serial for debugging (9600 baud)
  Serial.begin(9600);
  
  Serial.println("EEPROM module program started");
  
  // Write data
  writeEEPROM(0, 123);  // Write data 123 to address 0
  Serial.println("Data written to EEPROM");
  
  delay(100);  // Wait for write to complete
}

void loop() {
  // Read data
  int data = readEEPROM(0);  // Read data from address 0
  Serial.print("Data read from EEPROM: ");
  Serial.println(data);
  
  delay(2000);  // Wait 2 seconds
}

// Write EEPROM function
void writeEEPROM(int address, byte data) {
  Wire.beginTransmission(EEPROM_ADDR);
  Wire.write((int)(address >> 8));    // Address high byte
  Wire.write((int)(address & 0xFF));  // Address low byte
  Wire.write(data);                   // Write data
  Wire.endTransmission();
  delay(5);  // Wait for write to complete
}

// Read EEPROM function
byte readEEPROM(int address) {
  byte data = 0;
  Wire.beginTransmission(EEPROM_ADDR);
  Wire.write((int)(address >> 8));    // Address high byte
  Wire.write((int)(address & 0xFF));  // Address low byte
  Wire.endTransmission();
  Wire.requestFrom(EEPROM_ADDR, 1);  // Request 1 byte of data
  if (Wire.available()) {
    data = Wire.read();
  }
  return data;
}
EEPROM Memory running on an Arduino Uno

When it doesn’t work

Values come back wrong or as 255.
Writes need about 5 ms and the chip NAKs while busy. Use a library that waits, or add `delay(5)` after each write.
Nothing responds on the bus.
Run an I2C scanner. The address is usually 0x50 but the three address pins can move it to 0x51–0x57.
It worked for a week then a byte went bad.
Wear. You are rewriting one address too often — only write on change, or spread writes across a range.

Lessons using TK31

Each one is a working build, not a snippet.

Edit this page — content/modules/eeprom-memory.mdx

Community

Questions about this product

See what other owners have asked, and read their solutions.

Ask a question ↗

EEPROM Memory

Loading discussions…

Discuss this article

Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.

Browse Modules and blocks on the forum