Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.

EEPROM compile fail
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

EEPROM compile fail

by basrijn on Fri Mar 27, 2020 6:02 pm


Don't really know where this issue is coming from (on a Grand Central M4). Using PlatformIO in VS Code (all up to date). Adding EEPROM logic and my project fails to compile:

Code: Select all | TOGGLE FULL SIZE
src\main.cpp:2:10: fatal error: EEPROM.h: No such file or directory

I tried with both <EEPROM.h> and "EEPROM.h"
Downloaded the "eeprom" library from the PIO library manager

When I download the eeprom library I see the eeprom.h file in the libs directory.

Does the Grand Central not have an EEPROM and it's there a macro to make sure it never includes EEPROM.h?


Code: Select all | TOGGLE FULL SIZE
#include <Arduino.h>
#include "EEPROM.h"

uint16_t uniqueID;
unsigned long lastMillis;

void setup() {
  // put your setup code here, to run once:

void loop() {
  // put your main code here, to run repeatedly:

  // If millis has wrapped, reset
  if ( millis() < lastMillis ) {
    lastMillis = millis();

  // Every second
  if ( (millis() - lastMillis) > 1000 ) {
    // Let's read the EEPROM
    uniqueID = EEPROM.get(0, uniqueID);

    Serial.println(EEPROM.get(0, uniqueID), HEX);
    Serial.println(EEPROM.get(0, uniqueID), DEC);

    // We have seen both 0 and 65535 as uninitialized values
    if ( uniqueID == 65535 || uniqueID == 0 ) {
      Serial.println("EEPROM has no Unique ID, initialize now");
      uniqueID = random(1, 65534);
      Serial.print(".. Unique ID generated as: "); Serial.println(uniqueID);

    lastMillis = millis();

Posts: 81
Joined: Tue Nov 28, 2017 11:24 pm

Re: EEPROM compile fail

by adafruit_support_mike on Sun Mar 29, 2020 5:19 am

The SAMD microcontrollers don't have any EEPROM. They let you read and write the Flash array from normal code, so persistent data has to be handled differently.

The FlashStorage library works pretty well:

Posts: 61443
Joined: Thu Feb 11, 2010 2:51 pm

Re: EEPROM compile fail

by User_UMjT7KxnxP8YN8 on Sun Mar 29, 2020 11:38 am

You could also use the code I posted at to store settings in QSPI flash.

Posts: 173
Joined: Tue Jul 17, 2018 1:28 pm

Please be positive and constructive with your questions and comments.