1
\$\begingroup\$

I am trying to set the SM (sleep mode) register on the XBee radio. These registers can be set with so called AT Commands, listed from pg. 28 in the XBee/XBee Pro Product Manual.

This can be done using the X-CTU desktop application, either by typing the AT commands in the built-in terminal or by editing the values in a list and then click "Write".

But is it possible to modify these registers on the fly from a sketch running on the Fio?

\$\endgroup\$
2
\$\begingroup\$

Yes you can modify this on the fly. Make sure you are sending the necessary characters first with the required timing. The default is +++

After Xbee replies "OK" you can send your AT commands. As Swanand said don't forget the 0x0D at the end

\$\endgroup\$
  • \$\begingroup\$ This is all you need, send Serial.print("+++") to enable AT mode, wait for OK from the Xbee, and you can send the AT commands. To disable the AT mode, you can either wait a few seconds or send Serial.print("ATCN\r"). Never forget to send Carriage Return at the end of the AT commands, the only one that doesn't need CR is the +++ command \$\endgroup\$ – Jamiro14 Jun 22 '12 at 9:45
1
\$\begingroup\$

First of all, I never ever used an Arduino in my life but I have worked on XBee.

Yes, you can configure an XBee module on the fly. XBee accepts AT Commands. So the same commands you send from X-CTU are valid if you connect XBee to microcontroller serial port which is configured properly (in most cases, 9600 baud 8-N-1) and write over it.

Put your command in an array [AT] and write that array to serial port. You are done!

Note: All AT Commands are in ASCII and don't forget to add carriage return at the end (0x0D.)

\$\endgroup\$
  • \$\begingroup\$ The only way I know of sending anything to the radio is Serial.println() or Serial.print(). But all the XBee does is send those commands into the ether. I can hardly believe that it reads the characters passing through and if some of that looks like a command, then it executes that command instead. Please tell me if I misunderstood? Btw: I can't even test the commands with X-CTU because of another problem, described here. \$\endgroup\$ – Lucy Brennan Jun 7 '12 at 15:47
1
\$\begingroup\$

There you go.

void setup() {
  // Open serial connection to the xbee specifying the baud rate.
  Serial.begin(9600);

  // Define AT commands to rewrite the config once at startup
  // +++ -> Enters the AT mode
  // ATWR -> Saves the changes, ATAC doesn't work.
  // ATCN -> Exits AT mode
  // See http://widi.lecturer.pens.ac.id/Praktikum/Praktikum%20Mikro/XBee_ZB_ZigBee_AT_Commands.pdf
  const char *atcmds[] = {"+++", "ATNI Node_03\r", "ATWR\r", "ATCN\r"};

  // Write the commands to the xbee
  for(int i = 0;  i < sizeof(atcmds)/sizeof(atcmds[0]); i++){
     Serial.print(atcmds[i]);
     delay(1020);
  }
}
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.