arduino How to store variables in EEPROM and use them for permanent storage

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Syntax

  • EEPROM.write(address, value); //(Store variables in EEPROM in a particular address)
  • EEPROM.read(address); //(Retrieve values from EEPROM and read data stored in EEPROM)

Parameters

Parameters of EEPROM.writeDetail
addressThe address where value is to be stored in EEPROM
valueMain variable to store in EEPROM. Note that this is a uint_8 (single byte)—you must split multiple-byte data types into single bytes yourself. Or you can use EEPROM.put to store floats or other data types.
Parameters of EEPROM.ReadDetail
addressThe address from which the variable is to be read

Remarks

The allowable addresses vary by hardware.

  • ATMega328 (Uno, Pro Mini, etc.): 0–1023
  • ATMega168: 0-511
  • ATMega1280: 0-4095
  • ATMega2560: 0-4095

source



Got any arduino Question?