EEPROM not declared in this scope[SOLVED]

I have a very odd issue. I have a very small test program below that works fine. When I copy and paste the code into my much larger application and then compile I get EEPROM not declared in this scope. I have made sure that I have the same #include as below pasted in. Any ideas?

#include "spark_wiring_eeprom.h"

int loops = 0;
char line[80];

void setup()
   {
   Serial.begin(9600);
   delay(25000);
   Serial.println("start");
    }

void eepromWriteString(char* buffer)
   {
   int i = -1;
   do
      {
      i++;
      EEPROM.write(i,buffer[i]);
      } while (buffer[i] != 0);
   }

char* eepromReadString()
   {
   char buffer[100];
   int i = -1;
   do {
      i++;
      buffer[i] = (char) EEPROM.read(i);
      } while (buffer[i] != 0);
   return(buffer);
   }


void loop()
   {
   char data[20];
   sprintf(data,"test %d",loops);
   eepromWriteString(data);
   delay(1000);
   strcpy(data,eepromReadString());
   Serial.print("read = ");
   Serial.println(data);
   delay(10000);
   loops++;
   }

Also I notice that EEPROM.length() does not exist but is documented here Particle Documentation page

The length method is coming with the Photon update that will be out shortly. Unfortunately the doc got a little ahead of the released firmware at this point. It returns a constant that is different on the core and the photon, and in the future the electron.

As to your first problem, you should include “application.h” instead of the specific header since that will bring all of the wiring language to the party. In the near future this include file will be renamed.

If you try that and still get an error, paste the error message here so we can figure out which file is not getting the right header.

1 Like

@bko Thanks alot. What the problem was I had an old copy of application.h in my build directory that must NOT have had the right hooks to include the eeprom functions. That’s why including the spark_wiring_eeprom.h was masking the problem in my test application.

Thanks again.

1 Like