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()
{
Serial.println((long)test);
for (int i = 0; i < 5; i++)
{
Serial.println(test[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?