I'm working on a program with Arduino Uno which involves writing and reading EEPROM. I'm using a basic EEPROM library. My problem is: EEPROM values are preset to 255 whenever I burn my program. And there is nothing in my code which will write 255 in these bytes.

I even tried EEPROM_read example from the EEPROM library and got same result. I used EEPROM_clear code before EEPROM_read to set all values to 0. But when I read those values using EEPROM_read, they are 255.

Please help explain what is happening.


2 Answers 2


In flash and eeprom memory an erased value is 255. It's all about how flash memory works. If you want something other than 255 in there you will have to write something other than 255 in there.

  • I've written other values in EEPROM in my program, and those values are retained through program. But they are not retained when I re-flash the code. The EEPROM memory should be retained through multiple flashes. Commented Sep 13, 2016 at 6:13
  • Then you need, as @Cano64 has suggested, the EESAVE fuse setting. You can read more about setting fuses here: ladyada.net/learn/avr/avrdude.html - I don't know the Arduino bootloader well enough to say if you can do it through there or not - you may need a cheap hardware programmer (or another Arduino) to set the fuses through ICSP.
    – Majenko
    Commented Sep 13, 2016 at 9:31

You need to set EESAVE fuse

When the ATmega chip is programmed the memory is erased just before the new code is uploaded. Under normal circumstances the eeprom memory is erased as well as the program memory. The EESAVE fuse can be used to tell the chip not to erase the eeprom. This is useful when you want to upgrade code but keep user settings that are stored in eeprom.

The default value is EESAVE=1, not set and eeprom memory is erased during the chip erase cycle when programming.

This fuse calculator is quite handy.

  • Yes, the fuse calculator is really handy for knowing fuses, but how do I change these fuses using arduino. I'm working on a project with standalone atmega328. Commented Sep 13, 2016 at 6:06
  • You need a programmer for it (it can be another arduino), maybe you should make a new question about how to set fuses on arduino.
    – Cano64
    Commented Sep 13, 2016 at 14:23
  • I know that this is relatively an old topic but I wanted to express my experience here that this answer is the only solution to preserve EEPROM data. Once HIGH.EESAVE is set in your programmer, the EEPROM data will be preserved. My setup was AVRISP MKII and Atmel Studio 7.
    – Sener
    Commented Apr 11, 2017 at 14:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.