How to ask xbee's Node ID information through its serial connection to Arduino?

Hello everyone,

I am stuck in something that might be dumb. I am trying to find a way to “ask” the xbee series 2 its node identifier information in the arduino code. This xbee is connected to the arduino (through serial port, of course). Once the xbee replies, I would save this info in a variable and then I want to include it in the frame that later I send to other xbees.

I’d really appreciate any help. Thank you!
Alex

If your module is in AT mode you can query the Node Indicator register by simply issuing the ATNI command by itself with no other argument:

Serial.println("ATNI");

My modules are in API mode. Do I need to switch to AT in order to do this? Also, once the command is sent through the serial connection, how do i get the response? calling the Serial.read()?

Thank you very much!