Arduino UNO R4 WiFi EEPROM

Learn how to access the EEPROM memory on the UNO R4 WiFi.

In this tutorial you will learn how to access the EEPROM (memory) on an Arduino UNO R4 WiFi board. The EEPROM is embedded in the UNO R4 WiFi's microcontroller (RA4M1).

Goals

The goals of this tutorials are:

  • Write to the EEPROM memory,
  • read from the EEPROM memory.

Hardware & Software Needed

EEPROM

Electronically erasable programmable read-only memory (EEPROM) is a memory that can be used to store data that can be retrieved after power loss. This memory can be effective to use during run-time to log data can be used to re-initialize whenever a system comes back online.

When writing to the EEPROM memory, we specify two parameters: the address and value. Each byte can hold a value between 0-255.

1EEPROM.write(0,15); //writes the value 15 to the first byte

We are writing a value of

15
to the first byte available in the memory,
0
.

To read the value of this memory, we simply use:

1EEPROM.read(0); //reads first byte

There are several more methods available when working with EEPROM, and you can read more about this in the A Guide to EEPROM.

Please note: EEPROM is a type of memory with a limited amount of write cycles. Be cautious when writing to this memory as you may significantly reduce the lifespan of this memory.

EEPROM Write

A minimal example on how to write to the EEPROM can be found below:

1#include <EEPROM.h>
2
3int addr = 0;
4byte value = 100;
5
6void setup() {
7 EEPROM.write(addr, value);
8}
9void loop(){
10}

EEPROM Read

A minimal example of how to read from the EEPROM can be found below:

1#include <EEPROM.h>
2
3int addr = 0;
4byte value;
5
6void setup() {
7 Serial.begin(9600);
8 value = EEPROM.read(addr);
9 while (!Serial) {
10
11 }
12
13 Serial.print("Address 0: ");
14 Serial.println(value);
15}
16
17void loop() {
18}

Summary

In this tutorial, you've learned how to access the EEPROM on the UNO R4 WiFi board. To learn more about EEPROM, visit A Guide to EEPROM.

Suggest changes

The content on docs.arduino.cc is facilitated through a public GitHub repository. If you see anything wrong, you can edit this page here.

License

The Arduino documentation is licensed under the Creative Commons Attribution-Share Alike 4.0 license.