Each EEPROM cell is rated for roughly 100,000 writes. Do not write inside a fast loop.
What the message means
Flash-like memory wears with each write. Writing every loop pass could use up a cell in minutes.
Fix it in this order
- Use EEPROM.update() instead of write(). It skips writes when the value is the same.
- Save settings only when the user changes them, or when the robot stops.
- Spread frequent counters over several cells in turn.
- Check the rated number in the datasheet of your chip.
- On an ESP32 call commit() only when needed.
Why it happens
EEPROM cells wear a little with every write. The datasheet gives a number of write cycles that the maker guarantees, and a loop that writes on every pass can reach it surprisingly soon because a loop runs very fast.
Writing only when the value has changed, or only at a quiet moment, cuts the number of writes by orders of magnitude. The figure on this page is a typical rating, so read the one for your own chip.
If you see this, do this
| You see | Do this |
|---|---|
| Setting forgets or corrupts | Possibly worn or written during power loss. |
| Writing in loop() | Move writes out. |
Related
low memory, timing with millis.
Last reviewed: November 2026. These are the usual causes and the order that finds them fastest. Test on your own board; clones and cables differ.
Why this happens
EEPROM cells survive a limited number of erase-write cycles. The AVR datasheet rating is typically 100,000 per cell. The rating applies to each cell separately, so the danger comes from writing the same address over and over. A loop that writes every 10 ms reaches 100,000 writes in 1000 seconds, which is about 17 minutes.
Fewer writes is the main cure, and spreading writes across cells is the second. If you save a counter once a minute and rotate through 100 cells, each cell gets 1/100 of the writes, so the same rating lasts 100 times longer: 100,000 x 100 minutes is about 19 years.
How to confirm the cause
- Search the code for EEPROM.write, EEPROM.put and commit calls and see whether any sit in loop() without a condition.
- Add a counter that increments on each write and print it. A number that grows fast shows the problem.
- Compare the value you want to store with the stored value before writing.
- If values come back wrong, also check for power loss during a write.
Worked example
EEPROM.put compares and writes only changed bytes on AVR boards, but the explicit check also keeps the logic clear.
#include <EEPROM.h>
const int ADDR = 0;
int setting;
void setup() {
EEPROM.get(ADDR, setting);
}
void saveIfChanged(int v) {
if (v != setting) {
setting = v;
EEPROM.put(ADDR, setting); // writes only bytes that differ
}
}Common mistakes
- Calling EEPROM.write in loop() with no condition.
- Writing from an interrupt routine.
- Using EEPROM.write for an int, which stores only one byte.
- On an ESP32, forgetting EEPROM.begin(size) at start and commit() after writing.
If this did not fix it
- Check for lost power at the time of a write; use a checksum to detect partial data.
- Check for first-use values of 255 (0xFF) in a new chip.
- Consider an external FRAM chip if you need very frequent writes.
- On an ESP32, consider the Preferences library.