EEPROM is a handy, non-volatile storage space that works well for storing data such as calibration or tuning constants that are not practical to hard-code into Flash on microcontrollers which have it.
Many modern microcontrollers lack EEPROM but older ones like the ATmega328 on the classic Arduino Uno does have some.
The supported microcontrollers on the various Arduino and Genuino boards have different amounts of EEPROM: 1024 bytes on the ATmega328P, 512 bytes on the ATmega168 and ATmega8, 4 KB (4096 bytes) on the ATmega1280 and ATmega2560. The Arduino and Genuino 101 boards have an emulated EEPROM space of 1024 bytes.
Check the data for your microcontroller before looking to use EEPROM functions.
It is unusual to run out of EEPROM. And it is not often practical to use EEPROM to offload SRAM data. But it's mentioned here for completeness. Using EEPROM requires that you include the EEPROM library.
#include <EEPROM.h>
The EEPROM library provides several functions:
uint8_t read(int)
Read a byte from the specified EEPROM address
void write(int, uint8_t)
Write a byte to the specified EEPROM address
Note that while reads are unlimited, there are a finite number of write cycles (typically about 100,000).
Other functions
Refer to this Arduino page for additional functions.
Page last edited May 01, 2024
Text editor powered by tinymce.