EEPROM (Electrically Erasable Programmable Read-Only Memory) is a non-volatile memory technology that retains stored data without power and allows individual bytes or small pages to be erased and rewritten electrically, in-circuit, without removing the chip from the system.
In practice
EEPROM is commonly used to store small amounts of persistent configuration data, calibration values, device identifiers, counters, and user settings that must survive power cycles. Typical storage targets include Wi-Fi credentials, sensor trim values, product serial numbers, and runtime state that needs to be restored on next boot. For an example of how this looks in a modern RTOS context, see the blog post "Getting Started With Zephyr: Writing Data to EEPROM."
EEPROM comes in two physical forms in embedded designs: as a dedicated external IC (usually accessed over I2C or SPI, such as the Microchip 24-series (I2C) or some 25-series (SPI) parts, though note that some 25-series devices from various vendors are SPI flash rather than EEPROM) and as an integrated peripheral block embedded directly in the MCU. Many microcontrollers provide a small on-chip EEPROM block alongside their flash program memory, eliminating the need for an external component and simplifying BOM and board layout.
The most critical pitfall in EEPROM use is exceeding its endurance limit. Typical devices are rated for 100,000 to 1,000,000 erase/write cycles per byte or page. Writing frequently changing data, such as a real-time counter or a running log, directly to a single address will wear out that location quickly. Wear-leveling techniques, which distribute writes across multiple addresses, are the standard mitigation. The blog post "Important Programming Concepts (Even on Embedded Systems) Part I: Idempotence" is relevant here because write operations to EEPROM should ideally be designed to be idempotent, guarding against data corruption from interrupted writes.
Another common pitfall is confusing EEPROM with flash memory. While both are non-volatile, EEPROM supports byte- or small-page-level erase and rewrite (the internal controller handles erase/program cycles, so an explicit separate erase step is typically not required by the user), whereas flash generally has much larger erase granularity (sectors/pages) than EEPROM, with exact sizes varying by device. Some MCU vendors emulate EEPROM behavior in flash using a software layer; this is often labeled "data flash" or "EEPROM emulation" and carries its own set of constraints around sector wear and write granularity.
Discussed on EmbeddedRelated
Frequently asked
What is the difference between EEPROM and flash memory?
EEPROM allows individual bytes or small pages to be erased and rewritten independently, with the device's internal controller handling erase/program cycles.
Flash memory generally has much larger erase granularity: an entire sector must be erased before any byte in that sector can be reprogrammed, and exact sector sizes vary by device and vendor. EEPROM is better suited for frequently updated small data; flash is more area-efficient for large program or bulk data storage. Many MCUs that lack a dedicated EEPROM block provide a software EEPROM emulation layer on top of flash.
How do I avoid wearing out EEPROM prematurely?
Avoid writing to the same address on every event or at high frequency. Instead, use
wear-leveling: rotate writes across a pool of addresses and track which address holds the current valid value. Also consider writing only when data has actually changed, rather than unconditionally on each power-down. For a counter or log use case, accumulate updates in
RAM and flush to EEPROM only periodically or on a clean shutdown.
What happens if power is lost during an EEPROM write?
An interrupted write can leave the target byte or page in a corrupt or indeterminate state. The standard defense is to use a write-verify pattern: after writing, read back and compare. For multi-byte records, store a
checksum or
CRC alongside the data and validate it on read. Designing writes to be idempotent, meaning a repeated write of the same data produces the same valid result, further reduces the risk of persistent corruption.
My MCU does not have on-chip EEPROM. What are my options?
You can add an external EEPROM IC (
I2C or
SPI variants are widely available and inexpensive). Alternatively, most
MCU vendors provide an EEPROM emulation library that uses a pair of
flash sectors and a
wear-leveling scheme to present a byte-addressable non-volatile storage interface. Check your vendor's application notes; ST, NXP, Renesas, and others all publish ready-to-use emulation drivers.
How much data can I realistically store in EEPROM?
Dedicated external EEPROM ICs are typically sized in kilobits; for example, a 24C01 stores 1 Kbit (128 bytes), and common serial EEPROM devices top out in the hundreds of kilobits range (e.g., 512 Kbit = 64 KB). Densities much beyond that are uncommon for true EEPROM and are more often served by
SPI NOR flash. On-chip EEPROM in MCUs is typically much smaller, often 128 bytes to a few kilobytes, sized for configuration and calibration data rather than bulk storage. If your use case requires more space, consider SPI NOR
flash or an SD card instead.
Differentiators vs similar concepts
EEPROM is often confused with
flash memory. The key distinction is erase granularity: EEPROM erases at the byte or small-page level, while flash generally has much larger erase granularity (sectors/pages), with exact sizes varying by device and vendor. A related source of confusion is "EEPROM emulation," which is a software layer that mimics byte-level EEPROM semantics on top of a flash memory block; it is not true EEPROM hardware. Some vendors also use the term "data flash" for a flash region with smaller erase blocks intended for data storage, which sits between classic EEPROM and standard flash in behavior.