Chip ID

I'm working on a network of Arduino Pro Mini on a Xbee wireless network. I have a C# program monitoring all the units listening to the Serial data. Each unit (Arduino Pro Mini) has two functions.
1:) Controls a relay of a hamper door.
2:) listens to a limit switch condition (Open/Close) to determine if the hamper door is open.
When I send a command to the network, each of them hear the same command. Is there an ID each chip has that I can use in the if event function to send command directly to each chip individually. There can be as many as 100 chips in the network. so I was thinking there's got to be a way to ID each chip individually so I can program an event which only listens to the command meant for it.
Example:

Chip 1 receives command to open door:
Chip 2 - 99 receives command to keep doors locked while door 1 is closed.

When chip one door limit switch senses the door is shut, an all clear goes over the network to allow each of the doors to be accessible yet remain locked until access is granted to that hamper door.
Perhaps something like this:

#include <EEPROM.h>

char sID[7] = "CD1002";
char receivedChar;
boolean newData = false;
int LEDRed = 2;
int LEDBlue = 3;

void setup() {
 Serial.begin(9600);
  for (int i=0; i<6; i++) {
  // EEPROM.write(i,sID[i]);
   sID[i] = EEPROM.read(i);
 Serial.print(sID);
 Serial.println(" is ready for command!");
 digitalWrite(LEDRed, OUTPUT);
 digitalWrite(LEDBlue, OUTPUT);
 digitalWrite(LEDRed, LOW);
 digitalWrite(LEDBlue, HIGH);
  }
}


void loop() {
 recvOneChar();
 showNewData();
}

void recvOneChar() {
 if (Serial.available() > 0) {
 receivedChar = Serial.read();
 newData = true;
 }
}

void showNewData() {
 if (newData == true) {
 Serial.println(receivedChar);
   Serial.println(sID);
   if(receivedChar == 98){  //receive Command for CD1000 "b"
     if(sID == CD1002){
   digitalWrite(LEDBlue, HIGH);
   digitalWrite(LEDRed, LOW);
   Serial.println("Third Floor");
   }
   }
   else if (receivedChar == 97){ // All Clear!
   digitalWrite(LEDBlue, HIGH);   
   Serial.println("All Clear");
   }
   else{
     digitalWrite(LEDRed, HIGH);
   }
 newData = false;
 }
}

except the sID looks like it has to be converted to a string. Not sure the syntax for that.

Moderator edit:
</mark> <mark>[code]</mark> <mark>

</mark> <mark>[/code]</mark> <mark>
tags added.

There's no unique chip ID on the Pro Mini's ATmega328P microcontroller. I don't know about the Xbee.

You can give them an ID though. If you want to use the same code on all of them you could write the ID to EEPROM.

The sender is going to need to know the ID of each recipient so there is no substitute for hard work. In that case why not just build the ID into the program code something like

byte myID = 123;

Alternatively if you want to be able to have a standard program with the ID numbers added afterwards you could program in an ID of 0 and also have code that would tell the slave to contact the master to get a unique ID when it first runs, Then it could store the ID in the EEPROM. A lot more trouble than my first suggestion :slight_smile:

...R

What I do with every device is store a unique "serial number" in the top two or four bytes of EEPROM. This can be used later however you want. If using I2C or 9-bit MPC or simply a software protocol, use the top-most byte as the deviceID.

I don't know about the Xbee.

XBees have addresses. That is how they can be identified, so you don't need to use broadcast mode (which is slow). If the XBees are in API mode, your C# application can cause the sending XBee to send a packet to a specific XBee, and can tell which XBee send data to the receiver (or the Arduino that that XBee is connected to could tell).