[SOLVED] Error including EEPROM.h in Digispark-USB project

I am trying to use the build-in EEPROM with a Digispark, but am getting an error when including the header file :
#include <EEPROM.h>

fatal error: EEPROM.h: No such file or directory

I could not find any reference to this error with PlatformIO/Digispark online. There is mention of a similar problem with the Arduino IDE in a Digistump forum: “It looks like the Arduino team moved this library out of the global scope in recent releases” and I found a solution for that platform elsewhere: " What I did was COPY the EEPROM FOLDER in the arduino avr directory to the digispark library directory".

This does not seem applicable to PlatformIO since the folder structure is different. Any ideas on how to get the include working?

In which Arduino IDE version and board package version for that board does your code work?

I have not tried the code in the Arduino IDE since I do not currently have the IDE installed. I have been developing the project in PlatformIO from the start.

Well the EEPROM.h is really not there / included by default for the digispark-tiny board.

However, the EEPROM.h really is just a fancy wrapper for eeprom_write_byte() / eeprom_read_byte() from avr/eeprom.h. To be found here. You can just put this file in your src/ folder and then program as normal.

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

void setup() {
	EEPROM.write(0, 0xAB);
	uint8_t readback = EEPROM.read(0);
	Serial.println(readback, HEX);

void loop() {
1 Like

Thanks! Somehow it did not occur to me to just add a copy of EEPROM.h to src/, but it does the trick.