Skip to content

Ard Eeprom Update

DodaTech 1 min read

In this tutorial, you'll learn about Arduino EEPROM.update vs EEPROM.write Confusion. We cover key concepts, practical examples, and best practices to help you understand and apply this topic effectively.

The Problem

EEPROM.update() still wears out EEPROM despite the name suggesting it's safer.

Quick Fix

Wrong

EEPROM.update(0, 42);  // Update only writes if value changed
Works but misconception: update() still writes to memory if the value differs.
#include <EEPROM.h>

void writeWithCheck(int addr, byte val) {
  if (EEPROM.read(addr) != val) {
    EEPROM.write(addr, val);
    Serial.print("Written: ");
    Serial.println(val);
  } else {
    Serial.println("No change — skipping");
  }
}

void setup() {
  Serial.begin(9600);
  writeWithCheck(0, 42);  // Writes
  writeWithCheck(0, 42);  // Skips - no wear
}
Written: 42
No change — skipping

Prevention

EEPROM.update() internally reads first, then writes only if the value differs. This is equivalent to the manual check above. Always use update() instead of write() for wear leveling. For multi-byte structures, use EEPROM.put() which also does update-style checking.

DodaTech engineers apply these same patterns across Doda Browser, DodaZIP, and Durga Antivirus Pro for production IoT reliability.

FAQ

### Does update() completely eliminate wear?

No. It reduces wear by avoiding writes when the value hasn't changed. Each actual write still counts toward the endurance limit.

Is update() slower than write()?

update() does an extra read (microseconds), then an optional write (3.3 ms). The read overhead is negligible.

What about EEPROM.put()?

EEPROM.put() writes multi-byte types (int, float, struct) and uses update-style checking if available. Preferred for non-byte data.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro