EEPROM Read/Writes

Im trying to write some code that will read and write from EEPROM the device ID for each Arduino I have. However, how can I know what address the device ID wrote to so that I can read it? I guess Im confused by this part.

Say I have:

byte EEPROM_ADDR[255];

EEPROM.write(EEPROM_ADDR[0], Device 1);
EEPROM.write(EEPROM_ADDR[1], Device 2);

Can that work?

Looks to me like you’ve created an array with up to 255 members but you’ve not initialized those member values to anything useful. Are you trying to store device ID #1 in EEPROM location #1 ? If so you’ll need to set the array values = to the EEPROM addresses to be used. That is EEPROM_ADDR[0] = 0, EEPROM_ADDR[1] = 1, EEPROM_ADDR[2] = 2, etc, etc. Given this scheme I’m not even sure why you’re creating the array EEPROM_ADDR, you could just write the ID to the EEPROM address like :

EEPROM.write(0, Device1);     // stores ID #1 in the first EEPROM location, addr = 0
EEPROM.write(1, Device2);     // stores ID #2 in the second EEPROM location, addr = 1

I think I was confused when I was writing my pseudo code. I kept thinking from a user’s perspective of how to get the device ID, rather than from the programmer’s perspective (of just entering in some arbitrary address to save and read from).I was thinking in terms of large scale and random addressing. Following the KISS method, I dont need any of that.

Thanks for the clarification.