Arduino - Visual Studio Code error: 'EEPROM' was not declared in this scope

Hello, I got this error: error: ‘EEPROM’ was not declared in this scope on this line:
#include <EEPROM.h>

buffer[i]=EEPROM.read(readAddress++);
The EEPROM.h is already installed in the Build-in libraries. Any idea what is wrong?
Thank you in advance!

Full platformio.ini and code please.

[env:uno]
platform = atmelavr
board = uno
framework = arduino
monitor_speed = 57600

All examples gives an error on EEPROM

#include <Arduino.h>
#include <EEPROM.h>

int addr = 0;

void setup() {}

void loop() {
  int val = analogRead(0) / 4;

  EEPROM.write(addr, val);

  addr = addr + 1;
  if (addr == EEPROM.length()) {
    addr = 0;
  }

  delay(100);
}

What’s the exact output of the “Build” project task?

src/Flube.cpp: In function 'void loop()':
src/Flube.cpp:11:3: error: 'EEPROM' was not declared in this scope
   EEPROM.write(addr, val);
   ^~~~~~
src/Flube.cpp:11:3: note: suggested alternative: 'EECR'
   EEPROM.write(addr, val);
   ^~~~~~
   EECR
Compiling .pio/build/uno/FrameworkArduino/WString.cpp.o
Compiling .pio/build/uno/FrameworkArduino/abi.cpp.o
*** [.pio/build/uno/src/Flube.cpp.o] Error 1
Compiling .pio/build/uno/FrameworkArduino/hooks.c.o
==

I see.

So, on my machine the code builds fine.

Linking .pio\build\uno\firmware.elf
Checking size .pio\build\uno\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   0.5% (used 11 bytes from 2048 bytes)
Flash: [          ]   2.2% (used 720 bytes from 32256 bytes)
Building .pio\build\uno\firmware.hex
============================== [SUCCESS] Took 2.66 seconds ==============================

Please do the following:

  • remove all folders in C:\Users\<user>\.platformio\.cache
  • remove all folders in C:\Users\<user>\.platformio\lib
  • remove the folder C:\Users\<user>\.platformio\packages\framework-arduino-avr
  • remove the (hidden) .pio folder in the project
  • build again

Same error

Tool Manager: Installing platformio/framework-arduino-avr @ ~5.1.0
Downloading  [####################################]  100%          
Unpacking  [####################################]  100%
Tool Manager: framework-arduino-avr@5.1.0 has been installed!
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/uno.html
PLATFORM: Atmel AVR (4.0.1) > Arduino Uno
HARDWARE: ATMEGA328P 16MHz, 2KB RAM, 31.50KB Flash
DEBUG: Current (avr-stub) External (avr-stub, simavr)
PACKAGES: 
 - framework-arduino-avr @ 5.1.0 
 - toolchain-atmelavr @ 1.70300.191015 (7.3.0)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 6 compatible libraries
Scanning dependencies...
Dependency Graph
|-- FastLED @ 3.5.0
|-- EEPROM @ 2.0
Building in release mode
Compiling .pio/build/uno/src/main.cpp.o
Compiling .pio/build/uno/FrameworkArduino/wiring_analog.c.o
Compiling .pio/build/uno/FrameworkArduino/wiring_digital.c.o
Compiling .pio/build/uno/FrameworkArduino/wiring_pulse.S.o
Compiling .pio/build/uno/FrameworkArduino/wiring_pulse.c.o
src/main.cpp: In function 'void loop()':
src/main.cpp:11:3: error: 'EEPROM' was not declared in this scope
   EEPROM.write(addr, val);
   ^~~~~~
src/main.cpp:11:3: note: suggested alternative: 'EECR'
   EEPROM.write(addr, val);
   ^~~~~~
   EECR
Compiling .pio/build/uno/FrameworkArduino/wiring_shift.c.o
*** [.pio/build/uno/src/main.cpp.o] Error 1
======================================================================= [FAILED] Took 4.87 seconds =======================================================================

 *  The terminal process "platformio 'run', '--environment', 'uno'" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it. 

How does FastLED come into the equation here? I have feeling you’re suddendly using a either different platformio.ini or code than shown above.

Fastled is installed because I will need it for this projet. Without it, I have the same issue

Now the example is compiling but I still have the issue in my code. I’m digging.

I was using an ESP32. There is no eeprom on such processor!

The ESP32 Arduino core does have an EEPROM class which uses Flash to emulate EEPROM. This works nicely.