Arduino has a Unique ID!


(Luiz H. Cassettari) #1

Hello,

I have played with Arduino (Atmega328p) for a long time. In an old project, I needed to differentiate two Arduino Uno, so I try to find some kind of a Serial Number on the datasheet form the Atmega328p. The datasheet doesn’t have anything about Serial Number, and I implemented some ID with random and EEPROM, because I thought Atmega328p doesn’t have a Serial Number, but I found something interesting.

Last year I bought some SMD chips for a LoRa project, and I bought the Atmega328pb by mistake. This chip is kinda boosted version of the Atmega328p. A link of the difference between Atmega328p and Atmega328pb [here].

The interesting thing is this boost version chip has a Serial Number (10 bytes). So I can use this Serial Number to create a Unique ID for my Arduino/RFM95 device. Works perfect, but the boost chip just because of this feature… It’s much easier to buy an Arduino Pro Mini (Atmega328p).

Wait…

Maybe the Atmega328p have a Serial Number but the datasheet doesn’t say anything… And yes, Arduino chips have an unofficial Serial Number. By my tests looks like the Atmega328p has 9 Serial bytes. And I found an old datasheet of the Atmega328pb how shows 9 Serial bytes and confirm my assumption [here].

Maybe all AVR chips have a Serial Number. So I tested some Atmega328p and Atmega2560. All board I tested looks like have this unofficial Unique Serial Number.

That’s great!

Arduino has a Unique ID. And apparently, nobody knows… It’s an interesting building feature, for some projects this Unique ID is handy.

To make everything easier. I created a library to get the Unique ID (8 bytes) of the chip. ArduinoUniqueID.

That’s some Unique ID I collected.

Serial Unique ID: 34 39 31 30 36 0C 05 20
Serial Unique ID: 36 31 32 37 32 05 1B 17
Serial Unique ID: 36 35 30 32 37 10 17 0E
Serial Unique ID: 37 36 35 33 32 15 1B 15
Serial Unique ID: 37 36 35 33 32 15 19 0E
Serial Unique ID: 37 36 35 33 32 0F 1F 09
Serial Unique ID: 37 36 35 33 32 0F 1F 1A

I want to test others AVR Microcontrollers to check if the others boards have this Serial Number too.

If you find this feature useful, be free to use!

Stay tuned.


(Arjan) #2

Not to spoil the fun, but: it might have an ID that is unique to Arduino’s. But it’s not a globally unique EUI. So, what would you use it for, if a LoRaWAN device needs to have a EUI anyhow?

Related: DevEUI for non-hardware assigned values.


#3

if its unique or a manufacturers production batch serial number I don’t know.
Alsoo, like Arjan said, its not usable for LoRaWAN indentification.

But its probably usefull to encrypt your data before its encrypted by the network, if you need that, good find !


(Luiz H. Cassettari) #4

I don’t get it…
It’s an individual Serial Number to Represent a Unique ID. Each chip has a different number.
Looks perfect for DevEUI.


(Arjan) #5

Different for the specific device (or chip) manufacturer (assuming clones will never have duplicate serial numbers either). But nothing stops manufacturers of different devices to have the same serial number scheme.

A true EUI is guaranteed to be unique, if everyone adheres to the rules. (That is: only use registered EUIs, like TTN purchased a block of EUIs.)

In theory, the serial number could even match someone else’s true EUI. (That’s why even converting a unique MAC address to an EUI64 by inserting 0xFFFE in the middle is no longer officially approved.) Using a random EUI, adhering to the rules of random EUIs, at least avoids collisions with purchased EUIs. Of course, chances are low that duplicate numbers both happen to be used for LoRaWAN. (And even more so: with TTN.)

The ranges shown in the examples, do not seem to be registered.

Encryption needs a secure random value. Serial numbers are far too predictable for that.


(Amedee) #6

I don’t know for the AVR chips, but the SAMD ones also have a serial number. But it is not guaranteed to be unique and at the end of the day as already mentioned here it is not ‘globally’ unique.

An EUI-64 chip cost about 0.25 €, so why bother…


(Remko) #7

IMHO for some use cases having a quasi unique serial number, like the one we are discussing, can be usefull.
Usage of any number should be considered with the right arguments on pro- and con’s to fullfill the requirements.
So, I find it welcome to know that the number exists. And i might use it some time when I have the right usage for it. Thanks for sharing it with us!


(Amedee) #8

Yes, there might be use cases, but if I can’t get something guaranteed unique, I prefer to use the one randomly generated in the TTN console which at least will be unique for TTN.


(Andrisbirza) #9

All STM32 micro-controllers have 96 bit unique UUID, unique for every part that is manufactured by the ST.
UUID is made from wafer id, lot number and X,Y coordinates of the die on the wafer. Probably Atmel is doing something similar for the Atmega.


(Muro32) #10

How can I check it in if control structure?
Example;
if (uid != 573538323033052225 ) {
digitalWrite(ledPin, HIGH);
} else {
digitalWrite(ledPin, LOW);
}
Thank You


#11

see