Go Down

Topic: How to read the ID (serial number) of an Arduino? (Read 6 times) previous topic - next topic

HCF

Dec 16, 2009, 11:29 am Last Edit: Dec 16, 2009, 11:29 am by HCF Reason: 1
Hi all,

Is there a way to retrieve the ID ( serial number on the sticker on the back of the Arduino, e.g. "CD1234") of an Arduino via code?

I remember Phidgets offered that feature and i need it for my current feature. Suggestion for any means of identification of an individual Arduino are welcome. It should however best be independent of the code loaded on the Arduino and the data stored on the EEPROM.

Cheers

BenF

The FTDI chip (USB/serial interface) on the Arduino board has a unique serial number. You can query this number through the USB driver on the host (PC) side.

HCF

#2
Dec 16, 2009, 12:19 pm Last Edit: Dec 16, 2009, 12:19 pm by HCF Reason: 1
Thanks a lot, but i wonder, can the Arduino send this ID via serial?

PaulS

No. The Arduino can't read from the FTDI chip.

What difference does it make if it's a pull operation from the PC or a push operation from the Arduino? In other words, what are you trying to accomplish?

HCF

I am making a flexible network of arduino-embedded interactive components.

The Arduino's should be able to communicate their ID to each other,  so they can figure out how they are connected and what the overall geometry of the component assembly is.

From your replies i figure the only way to do this is to once write the Arduino serial number to the EEPROM and then read it back whenever needed. Unless... there are other ways to do it?

MikMo

Another approach is to give each Arduino a  unique address, either in the softwarre or by attaching a 4 (or 5/6/7/8) position dip switch to some digital pins.


Grumpy_Mike

Quote
so they can figure out how they are connected


That's OK

Quote
and what the overall geometry of the component assembly is.

That is very tricky. Have you though how this would happen. Each arduino will have it's own unique map because it is a unique position in the topology. It will also be impossible to do this with a simple broadcast message system, you will need at least a pair of input / output communication links per arduino.

HCF

Here's the code which works for me.
It is important to minimize how often the EEPROM is read from and written to, because it has a life estimate of only 100.000 read/write cycles.

Code: [Select]
// WRITES ARDUINO SERIAL TO EEPROM
//
// do this only once on an Arduino,
// write the Serial of the Arduino in the
// first 6 bytes of the EEPROM

#include <EEPROM.h>
char sID[7] = "CD6484";


void setup()
{
 Serial.begin(9600);
 for (int i=0; i<6; i++) {
   EEPROM.write(i,sID[i]);
 }
}

void loop() {
 Serial.println(sID);
}


Code: [Select]

// READS ARDUINO SERIAL FROM EEPROM
//
// reads the Serial of the Arduino from the
// first 6 bytes of the EEPROM

#include <EEPROM.h>
char sID[7];


void setup()
{
 Serial.begin(9600);
 for (int i=0; i<6; i++) {
   sID[i] = EEPROM.read(i);
 }
}

void loop() {
 Serial.println(sID);
}





HCF

#8
Dec 17, 2009, 10:28 am Last Edit: Dec 17, 2009, 12:17 pm by HCF Reason: 1
Quote

Another approach is to give each Arduino a  unique address, either in the software or by attaching a 4 (or 5/6/7/8) position dip switch to some digital pins.


that sounds interesting! for my application it would be not ideal though, i'd never want to change the switches and i'd loose a few pins

Groove

Quote
It is important to minimize how often the EEPROM is read from and written to, because it has a life estimate of only 100.000 read/write cycles.

That's incorrect - you can read as often as you like, the limitation is on erase/write cycles.
Per Arduino ad Astra

HCF

#10
Dec 17, 2009, 10:39 am Last Edit: Dec 17, 2009, 12:23 pm by HCF Reason: 1
Quote
That is very tricky. Have you though how this would happen. Each arduino will have it's own unique map because it is a unique position in the topology. It will also be impossible to do this with a simple broadcast message system, you will need at least a pair of input / output communication links per arduino.


We have Arduinos linked up via '4052' multiplexers.
Each Arduino listens to four other Arduinos in turn, and sends to 'their' multiplexers as well. Listening in works well, we still have to see whether it works bi-directionally.

I'll try to have the Arduino network broadcast information on individual connections over time (like 'i'm no. 1337 and i'm next to you!', 'i'm no. 42 and i'm connected to no. 1337!').This way, they could have at least a map of their immediate neighbourhood.

A custom-made modeler app will collect this information and adapt the representation of the assembly:
[media]http://www.youtube.com/watch?v=U9EO8azX8zo[/media]



HCF

#11
Dec 17, 2009, 10:41 am Last Edit: Dec 17, 2009, 10:41 am by HCF Reason: 1
Quote
That's incorrect - you can read as often as you like, the limitation is on erase/write cycles.


indeed, i failed at RTFM  ::)

DingbatCA

Thanks HCF, that was the exact code I was looking for.

alm7100

How about using a DS2401 its has a unik ID and uses one wire.

hector albornoz

You can also assign or code generated by the software ID eg 485fcba0-e61a-11df-9492-0800200c9a66, and left as a global variable. (This number may be repeated once every 100 years)
So no need to remove the FTDI or an EEPROM.

Or the second option is with the Dallas DS2401, separates a unique pin (Wire one), this number is unique.


http://www.arduino.cc/en/Reference/EEPROM
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1260959358/11
http://www.famkruithof.net/uuid/uuidgen
http://pdfserv.maxim-ic.com/en/ds/DS2401.pdf


Code:
/ / WRITES TO SERIAL EEPROM Arduino
/ /
/ / Do this only eleven on an Arduino,
/ / Write the Serial of the Arduino in the
/ / First 6 bytes of the EEPROM

# Include <EEPROM.h>
sID char [7] = "CD6484";


void setup ()
{
 Serial.begin (9600);
 for (int i = 0; i <6; i + +) {
   EEPROM.write (i, sID );
 }
}

void loop () {
 Serial.println (sID);
}



Code:
/ / Arduino READS FROM SERIAL EEPROM
/ /
/ / Reads the Serial of the Arduino from the
/ / First 6 bytes of the EEPROM

# Include <EEPROM.h>
sID char [7]


void setup ()
{
 Serial.begin (9600);
 for (int i = 0; i <6; i + +) {
   sID = EEPROM.read (i)
 }
}

void loop () {
 Serial.println (sID);
}

Go Up