Arduino reading and writing string to EEPROM

The arduino EEPROM library only provides functions to read and write one byte at a time from the internal EEPROM. Note that EEPROM has limited number of writes.

In this tutorial I will provide some functions to store string to EEPROM and Read back to String variable. String is basically character array terminated with null (0x00).

The microcontroller on the Arduino and Genuino AVR based board has EEPROM: memory whose values are kept when the board is turned off (like a tiny hard drive). EEPROM library enables you to read and write those bytes only.

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.

Arduino Example code to store and Read String from EEPROM

 

Results

Upload above code to Arduino board and open serial monitor with 9600 baud rate, you will see following results.

Related more information

https://circuits4you.com/2016/12/14/internal-eeprom-esp8266/

One thought on “Arduino reading and writing string to EEPROM

Leave a Reply