I am relatively new to Arduino and I am currently writing some code to control a relay board. The on/off times are provided by the user at run-time and should be stored persistently (EEPROM or flash) in case of power-down.

On my Uno I worked with the EEPROMex library and that worked well. Now I have a Due which doesnt have any EEPROM and I am struggling how to store variables persistently. Specifically, I dont know how to access whatever I wrote to the flash memory previously. In the example below the content of test[] is obviously overwritten on every restart.

PROGMEM int test[] = {1, 2, 3, 123, 23};

void test()
  for (int i = 0; i < 5; i++)

I noticed that the address does not change during re-starts, so I I tried reading/writing beyond index 4. This out-of-bounds read/write worked, I guess since I am anyway not storing anything else. Interestingly even this memory which is out of the array is overwritten on power-up.

So: How do I store on unser input data (variables) persistenly on an Arduino due without using any shields?

  • You don't need a whole shield for EEPROM. Just 4 or 5 wires and an EEPROM DIP-chip.
    – Gerben
    Commented Jul 1, 2015 at 12:52

3 Answers 3


I really hope that somebody knows differently, but I'm fairly sure that the answer is that you can't directly save runtime data back to the Arduino Due board. I've looked into this myself and have only found answers saying "wire up an external EEPROM" or similar. Whilst it seems that it should be technically possible to write into unused (or pre-reserved) areas of the program memory, I suspect that the CPU has to be put into a special mode to do this, which is very probably only possible from the bootloader when flashing a new program to it.

I've chosen to go with FRAM chips for data storage. Link to mine. They are difficult to wire up - the only ones I found were in surface mount packages (although some hobby retailers sell them mounted to little boards with header pins), but they are very cheap, very durable (you can write to them a great number of times before they wear out), operate at high speeds and you can read/write single bytes from/to them. Other storage chips often require you to write whole "pages" of data at a time which can mean reading in the existing data, modifying it, then writing it back.

Additional comments: In your original question, you state that the contents of your PROGMEM located array must be restored on restarts. I don't think this is the case. That would suggest that the contents are stored elsewhere and code is in place to overwrite them, however it could be the case that they are copied into working RAM, which would mean that the PROGMEM macro is not actually doing anything on the Due - which may well be the case.

Modify your code to change one of the values of the array (within the bounds of the array!) and then print its value out again after changing it. If the value printed has changed then this means that PROGMEM is not actually doing what it is supposed to do on the Due, which would be a real shame.

  • Adafruit sells FRAM on a breakout board which is a lot easier to deal with when everything else is thru-hole. Plus FRAM are crazy fast compared to EEPROM.
    – JRobert
    Commented Jul 1, 2015 at 15:29
  • The SAM3X8E has also backup domain (several backed up registers, RTC), but its power supply is shorted to the main 3V3 rail on DUE board, so there is no easy way to add battery.
    – KIIV
    Commented Feb 19, 2020 at 15:05

This library called DueFlashStorage was created by Sebnil and is in the Arduino Library Database Tool!

It basically takes the EEPROM functionality and applies it to the Flash storage on the DUE. The only drawback is that the flash memory gets erased every time you upload a new (or new version of a) sketch.

For my application that works but for other applications that might not be what you want!

Click here to go to the GitHub for it called DueFlashStorage


Without an external device you won't be able to store data permanently. So it might not be a full shield, but you'll have to add SOMETHING. Depending on how much data you need you might use components that have EEPROM as a side feature. For instance, as explained here, the DS1337 RTC module has 56 spare bytes of EEPROM^H^H^H^H^H^H Non-Volatile RAM available. I know, it sure isn't much, BUT it might be enough for your needs, depending on how much you need to store.

And of course it provides you with DateTime capabilities, wich could come in handy.

Aside from this, there are EEPROM chips mounted on a small board, with DIP switches to set the I2C address, which would be very discrete, and could store a large amount of data. See this one for instance.

  • 1
    Technically the DS1337 memory is not called EEPROM, but battery backed RAM. You can abuse the alarm sections to get an additional 7 bytes :-). I used this trick on the DS3231 which doesn't have any 'free memory'.
    – Gerben
    Commented Jul 1, 2015 at 12:49
  • You're right. The datasheet says "56-byte, battery-backed, nonvolatile (NV) RAM for data storage". Neat trick you did abusing the alarm section ;-)
    – dda
    Commented Jul 2, 2015 at 10:41

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.