Hello Everyone.
I have an issue regarding Arduino Mega2560 Unique Serial ID number.
I need unique IDs each any every mega2560 chips in my project, So i am using
ArduinoUniqueID.h
ArduinoUniqueID library for that.
But there is an issue occurs. i tested more than 5 mega2560 chips in that some chips gives 9 bytes IDs proper like "6E756E6B776F000E12" , etc.
but i get some IDs like "58FFFEFFFEFFFFFFFF" this and main issue is that 2 mega2560 chips get same id how that possible?
Is there any issue in library or in mega2560 chip it is possible?
what's the solution for that?
Is any one have any idea or solution regarding this please help me.
Thank you.
Maybe you got some fake chips? Where did you get them?
1 Like
A ATmega2560 microcontroller does not have an unique ID; so whatever is generated is kind of luck.
The library (ArduinoUniqueID/src/ArduinoUniqueID.cpp at master · ricaun/ArduinoUniqueID · GitHub) uses id[i] = boot_signature_byte_get(0x0E + i + (UniqueIDsize == 9 && i > 5 ? 1 : 0));
. The boot_signature_byte_get returns a byte at a specific location and it depends on what is stored from factory in that location what you get; so if there are two chips that have that same value store (e.g. as a calibration byte) you will not get a unique number. I unfortunately do not know what the address (exactly) contain. Part of that specific memory is the chip ID (the same for all ATmega 2560 microcontrollers) and the calibration byte (can be different).
If you need an unique number for a PC application, you should use the serial number of the 16U2. This however requires that you don't use Mega boards with CH340.
An alternative (to my knowledge) is to add a one-wire device which has a unique ID to your boards.
We just set set an ID in the EEPROM and read it out in setup(). This requires a sketch to set the ID before before loading the actual code. Of course this assumes there is no malicious operator that wants to change the ID. We use it for a unit ID so that we can display it and add it to logged data.