How To Install Using Arduino Library Manager
Initial Version v1.0.0
1. Add support to SAMD51 family such as Itsy-Bitsy M4, etc. in addition to some SAMD21 boards (Arduino Zero, Arduino MKR1000, Nano-33 IoT) currently supported by the original FlashStorage library
Library is based on and modified from:
1. Cristian Maglie's FlashStorage library
The FlashStorage library aims to provide a convenient way to store and retrieve
user's data using the non-volatile flash memory of microcontrollers.
The flash memory, due to his properties, is generally used to store the firmware
code, but it can also be used to store user data.
Currently, ATSAMD21 and ATSAMD51 are supported (and consequently every board based on
this cpu like the Arduino Zero, Arduino MKR1000, Nano-33 IoT, Adafruit Itsy-Bitsy M4, Metro M4, etc).
This is the code of StoreNameAndSurname
// Create a structure that is big enough to contain a name
// and a surname. The "valid" variable is set to "true" once
// the structure is filled with actual data for the first time.
// Reserve a portion of flash memory to store a "Person" and
// call it "my_flash_store".
// Note: the area of flash memory reserved lost every time
// the sketch is uploaded on the board.
// Create a "Person" variable and call it "owner"
// Read the content of "my_flash_store" into the "owner" variable
owner = my_flash_store.read();
// If this is the first run the "valid" value should be "false"...
if (owner.valid == false)
// ...in this case we ask for user data.
SERIAL_PORT_MONITOR.println("Insert your name:");
String name = SERIAL_PORT_MONITOR.readStringUntil('\n');
SERIAL_PORT_MONITOR.println("Insert your surname:");
String surname = SERIAL_PORT_MONITOR.readStringUntil('\n');
// Fill the "owner" structure with the data entered by the user...
// set "valid" to true, so the next time we know that we
// have valid data inside
owner.valid = true;
// ...and finally save everything into "my_flash_store"
// Print a confirmation of the data inserted.
SERIAL_PORT_MONITOR.print("Your name: ");
SERIAL_PORT_MONITOR.print("and your surname: ");
SERIAL_PORT_MONITOR.println("have been saved. Thank you!");
// Say hello to the returning user!
SERIAL_PORT_MONITOR.println(", nice to see you again :-)");
// Do nothing...