The task is to read and display all EEPROM (Electrically Erasable Programmable Read-Only Memory) data on a serial terminal (e.g., PuTTY, Arduino IDE) in a structured HEX format.
EEPROM is a non-volatile memory used to store small amounts of data that must be preserved even after power loss.
Requirements:
Example Output:
0000: 3A 6F 9C 00 14 FF 23 7E 11 0A 55 42 80 91 00 3C
0010: 12 00 34 FF 89 21 7A 5E 09 7F 66 88 44 00 00 10Concept
The program reads EEPROM sequentially, groups data in 16-byte blocks, and prints address–data pairs for easy analysis, debugging, or memory verification.
Below are the solutions to the given task using the following microcontrollers
We are using the ESP32 DevKitC v4 development board and programming it using the Arduino IDE.
ESP32 does not have a real EEPROM chip inside. Instead, part of its Flash memory is used to simulate EEPROM behaviour.
Connect the ESP32 development board to your computer using a USB cable.
#include <EEPROM.h>
// Configuration
#define EEPROM_SIZE 512 // Flash-backed EEPROM emulation size (max ~4096 on ESP32)
#define BYTES_PER_ROW 16 // Hex bytes per printed row
#define START_ADDR 0x0000
#define END_ADDR 0x01FF
// Compile-time guards
#if (END_ADDR >= EEPROM_SIZE)
#error "END_ADDR must be <= EEPROM_SIZE - 1"
#endif
#if (START_ADDR > END_ADDR)
#error "START_ADDR must be <= END_ADDR"
#endif
void printEEPROMMap();
void setup() {
Serial.begin(115200);
// Initialize EEPROM emulation; required before read/write ops.
EEPROM.begin(EEPROM_SIZE);
// display the contents of memory(Hex + ASCII with address window).
printEEPROMMap();
// Free EEPROM internal buffers
EEPROM.end();
}
void loop() {
// No operations in the loop.
}
// Prints a hex table of EEPROM bytes from START_ADDR to END_ADDR.
// Format:
// Address | 16 bytes in hex | ASCII
void printEEPROMMap() {
Serial.println(F("\nESP32 EEPROM Memory Map"));
Serial.println(F("---------------------------------------------------------------------"));
Serial.println(F("Address | 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F | ASCII"));
Serial.println(F("---------------------------------------------------------------------"));
char ascii[BYTES_PER_ROW + 1]; // Holds printable ASCII for each row
ascii[BYTES_PER_ROW] = '\0';
for (uint16_t base = START_ADDR; base <= END_ADDR; base += BYTES_PER_ROW) {
// Row prefix: 16-bit hex address, zero-padded.
Serial.printf("0x%04X | ", base);
// Print hex bytes and build ASCII column.
for (uint8_t offset = 0; offset < BYTES_PER_ROW; offset++) {
uint16_t addr = base + offset;
if (addr <= END_ADDR) {
uint8_t data = EEPROM.read(addr);
Serial.printf("%02X ", data);
// Printable ASCII range 0x20..0x7E; use '.' otherwise.
ascii[offset] = (data >= 0x20 && data <= 0x7E) ? static_cast<char>(data) : '.';
} else {
// Pad hex area for incomplete final row.
Serial.print(" ");
ascii[offset] = ' ';
}
}
// ASCII column
Serial.print("| ");
Serial.println(ascii);
}
}
printEEPROMMap(), and then ends EEPROM access.printEEPROMMap();EEPROM.begin(512);EEPROM.read(address);EEPROM.end();EEPROM.begin(8000)) can corrupt other Flash data or cause runtime errors.EEPROM.commit() only when values actually change. EEPROM.commit() after writingWe are using the Arduino UNO development board and programming it using the Arduino IDE.
Connect the Arduino UNO development board to your computer using a USB cable.
We are going to use EEPROM.h library to implement this task. In Arduino UNO, there is a separate EEPROM chip available of 1KB.
#include <EEPROM.h>
// Define the size of EEPROM (varies depending on microcontroller)
const int EEPROM_SIZE = 512; // For Arduino Uno, update based on your board's EEPROM size.
const int BYTES_PER_ROW = 16; // Bytes to display per row
void setup() {
Serial.begin(9600);
while (!Serial);
Serial.println("EEPROM Memory Map:");
Serial.println("Address | Data (in Hex)");
Serial.println("-------------------------");
printEEPROMMap();
}
void loop() {
// No operations in the loop.
}
void printEEPROMMap() {
for (int i = 0; i < EEPROM_SIZE; i += BYTES_PER_ROW) {
// Print starting address of the row
Serial.print("0x");
if (i < 16) Serial.print("0"); // Formatting for single-digit addresses
Serial.print(i, HEX);
Serial.print(" | ");
// Print the data in hexadecimal format
for (int j = 0; j < BYTES_PER_ROW; j++) {
if (i + j < EEPROM_SIZE) {
byte data = EEPROM.read(i + j);
if (data < 16) Serial.print("0"); // Ensure two digits
Serial.print(data, HEX);
Serial.print(" ");
} else {
// If out of bounds, print placeholder
Serial.print("-- ");
}
}
Serial.println();
}
}
setup()printEEPROMMap().loop()printEEPROMMap()BYTES_PER_ROW (16), prints the row’s starting address and the next 16 bytes in hexadecimal, padding with -- if past the end.EEPROM.length()EEPROM.begin(size).EEPROM.read(address)The below output is of the EEPROM (after writing random values)

The below output is of the Formatted EEPROM. (Writing 0xFF to all EEPROM locations)
