Pages: [1]   Go Down
Author Topic: How to read the ID (serial number) of an Arduino?  (Read 6759 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 10
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
« Last Edit: December 16, 2009, 05:29:29 am by HCF » Logged

Offline Offline
Edison Member
*
Karma: 3
Posts: 1001
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 10
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks a lot, but i wonder, can the Arduino send this ID via serial?
« Last Edit: December 16, 2009, 06:19:46 am by HCF » Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 653
Posts: 50883
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 10
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Copenhagen / Denmark
Offline Offline
Edison Member
*
Karma: 6
Posts: 2360
Do it !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 639
Posts: 34725
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 10
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
// 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:
// 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);
}



Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 10
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
« Last Edit: December 17, 2009, 06:17:27 am by HCF » Logged

UK
Offline Offline
Faraday Member
**
Karma: 17
Posts: 2884
Gorm deficient
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Per Arduino ad Astra

0
Offline Offline
Newbie
*
Karma: 0
Posts: 10
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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]


« Last Edit: December 17, 2009, 06:23:35 am by HCF » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 10
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

indeed, i failed at RTFM  :smiley
« Last Edit: December 17, 2009, 04:41:40 am by HCF » Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 75
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Odense
Offline Offline
Jr. Member
**
Karma: 1
Posts: 60
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

0
Offline Offline
Newbie
*
Karma: 0
Posts: 10
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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);
}
Logged

Pages: [1]   Go Up
Jump to: