I am building some remote sensor nodes for arduino, they will use RF to transmit data back to a base station. Is there some sort of unique id backed into arduino that I can use to identify the remote arduino sensor node to the base station? If not, how do others solve this issue?
I realize that I could hard code a nodeid when I compile the source for that node, just seems like that would not scale too well. What I need is something analogous to a mac address in http land.
(sorry for bad english, I'm German)
As far as I know, the Arduino does not have an unique product ID, but after a reset every byte in the RAM has a random value which is different on every arduino.
This program should output a different value on every arduino.:
void setup()
{
uint32_t checksum = 0;
for(uint16_t u = 0; u < 2048; u++)
{
checksum += * ( (byte *) u );//checksum += the byte number u in the ram
}
Serial.begin(115200);
Serial.println(checksum , HEX);
}
void loop()
{
}
UPDATE:
You could just write a number on the eeprom once -> You have your unique ID
It's annoying there is no hardware ID available on Arduino devices. I created tiny library (70 lines of code) to store your own ID in EEPROM memory and verify it later.
You can use it to prevent installation of wrong sketch on your device and damage peripherals or for any other similar purposes:
https://github.com/skoumalcz/arduino-id-guard
i'm sorry but all the atmega chip i know won't give an Unique ID, but the series xmega does (but then you are really far from arduino).
You can put a value in the eeprom at compile time, but as said won't scale well.
Unless, as mpflaga you can write the SN# directly to the EEPROM with the "-U eeprom:w:mydata.eep" arguments.
You can also implement somenthing like requesting the ID in the bus, and if it is free use and store it, but will add a lot of complexity to your protocol
I stumbled on this question while trying to find answer myself and decided to go with DS2401 referenced in the link provided in comments (arduino.cc forum: "Arduino serial number S/N ?").
I will have 1-wire bus on my project anyway so having one extra (and quite cheap) component doesn't matter and it will provide globally unique id regardless of the board model and chips used (applies also to clone mfgs, for example I have couple of DCcduino UNO boards that have CH340G for comms instead of Arduino UNO's Atmega8U2/Atmega16U2 and other Arduino boards' FTDI).
I know it's an old post, but I was curious how you solved the problem. I am currently generating a unique ID with a check digit at the end (using the same approach as UPC codes).
I would currently use an external program to manage my serial numbers before writing them to EEPROM using a separate sketch. All of this controlled via a build process. Sounds complicated, but I couldn't really think of a better way (short of hard coding the Serial #).
I considered the DS2401 approach; however, I couldn't justify the extra hardware. I did not see the difference between writing to EEPROM and having yet another hardware component with a serial written to it.
I also have a SerialNumber class that reads the data that can be used in any project.