Getting the correct XBee serial number

I am trying to access the high and low serial number of the XBee Pro attached to my Arduino. I use the following code to read the values.

byte SH[4]; // XBee Serial Number High
byte SL[4]; // XBee Serial Number Low

// Get the XBee Serial Number

XBee.print("+++");
delay(3000);
XBee.println(“ATSH”);
XBee.readBytes(SH, 4);
XBee.println(“ATSL”);
XBee.readBytes(SL, 4);
delay(10000);

I then use the following code to print the results:

// Print XBee Serial Number High (SH)
Serial.print("XBee Serial Number High: ");
for (i = 0; i < 4; i++) {
Serial.print(SH*, HEX);*

  • Serial.print(" ");*
  • }*
  • Serial.println();*
  • // Print XBee Serial Number Low (SL)*
  • Serial.print("XBee Serial Number Low: ");*
  • for (i = 0; i < 4; i++) {*
    _ Serial.print(SL*, HEX);_
    _
    Serial.print(" ");_
    _
    }*_
    The actual serial number of the XBee I am using is 0013A200 40E3746C
    What prints out is:
    XBee Serial Number High: 4F 4B D 31
    XBee Serial Number Low: 5 C9 82 6A
    I want transmit the XBee serial number to the base unit so I can match that number with a location number saved by reading the XBee serial number and comparing it to the saved value. Why don’t the numbers match?

Why don't the numbers match?

Let's address a different question, first. Why didn't you post your code correctly? There are stickies at the top of the forum that show how, that you were supposed to read BEFORE blundering in here.

Then, consider the fact that you send a command, via serial, to the XBee and expect a response within a few nanoseconds, even though the command has not had time to get to the XBee.

You read, or try to, 4 bytes from the XBee, and ignore what it tells you about how many bytes were available to be read, Then, you ASSume that all the data in the array is valid.

Well, I do not!

I am trying to access the high and low serial number of the XBee Pro attached to my Arduino. I use the following code to read the values.

byte SH[4];                  // XBee Serial Number High
byte SL[4];                  // XBee Serial Number Low


  // Get the XBee Serial Number

  XBee.print("+++");
  delay(3000);
  XBee.println("ATSH");
  XBee.readBytes(SH, 4);
  XBee.println("ATSL");
  XBee.readBytes(SL, 4);
  delay(10000);

I then use the following code to print the results:

  // Print XBee Serial Number High (SH)
  Serial.print("XBee Serial Number High: ");
  for (i = 0; i < 4; i++) {
    Serial.print(SH, HEX);
    Serial.print(" ");
  }
  Serial.println();
  // Print XBee Serial Number Low (SL)
  Serial.print("XBee Serial Number Low: ");
  for (i = 0; i < 4; i++) {
    Serial.print(SL, HEX);
    Serial.print(" ");
  }

The actual serial number of the XBee I am using is 0013A200 40E3746C

What prints out is:

XBee Serial Number High: 4F 4B D 31
XBee Serial Number Low: 5 C9 82 6A

I want transmit the XBee serial number to the base unit so I can match that number with a location number saved by reading the XBee serial number and comparing it to the saved value. Why don’t the numbers match?

Why don't the numbers match?

Because some part of your code is wrong. But, since you won't post all of it, so we can try it out, you are on your own fixing it.