MegunoLink’s EEPROM Id Writer panel in the Program Devices visualizer lets you easily write unique Ids to your Arduino devices. A unique Id is useful when several devices are communicating over a radio, wireless or CAN network with each other. It lets the different devices be identified on the network.
Device Ids are written to the Arduino’s eeprom at a location and format that you configure. You will need an ISP programmer, such as the AVR ISP Mk II, to write device ids because normal serial bootloaders don’t allow you to write to the eeprom.
Create a Panel to Write Unique Ids
To create a panel for writing unique ids to your Arduino devices, click the Add Programmer drop-down menu on the Program Devices visualizer toolbar. Select EEPROM Id Writer from the list.
Configuring the Unique Id Writer Panel
Click the Configure button to configure the format of the Id written using the configuration dialog box:
The EEPROM address sets the location where the first byte of the ID will be written. This can be any address in the eeprom, but you should take care that it is not overwritten when your Arduino program saves settings. The number of bytes in the eeprom used by the id will depend on the format.
MegunoLink supports several formats for writing ids. You should pick one large enough for the number of unique ids you will use. Unless you are short of EEPROM memory or need an Id compatible with another library, it is safest to pick the largest size. Supported formats include:
- 1 byte numeric: id is a number from 0 to 255. It will take up 1 eeprom location
- 2 bytes numeric: id is a number from 0 to 65,535. It will take up 2 eeprom locations
- 3 bytes numeric: id is a number from 0 to 16,777,216. It will take up 3 eeprom locations
- 4 bytes numeric: id is a number from 0 to 4,294,967,296. It will take up 4 eeprom locations
- 2 letters + 2 bytes numeric: id is two letters followed by a number between 0 and 65,535. For example:
AB1234
.
Ids can be written in big-endian order (also known as network byte order) or little-endian order. Most Arduino processors use little-endian byte order, so we recommend little-endian order. See Endianness on Wikipedia for more information.
After configuring the Id format, you can use the Test button to examine the bytes MegunoLink will write for the current id.
The third row of the Id Writer panel lets you select the programmer that will be used. Most Arduino Serial bootloaders don’t support writing to the eeprom to save space. So you will need to use an ISP programmer such as the AVR ISP Mk II.
Writing the Unique Id to your Arduino
The next id that will be written, when the Program button is pressed, is shown on the second line. The number of fields available depends on the format selected. When the Auto-increment box is checked, the next Id will be increased by one each time a device is programmed successfully. The + button lets you increment the next Id by one manually.
When Verify is turned on, the value will be read back after writing to check that no errors occurred.