Configuring XBee without XCTU

Hello, I am quite new to arduino and I would like to configure my Xbee S1 (which is pluged into my arduino with a Bees Shield v2.12 from seedstudio) without having to use XCTU. More precisely I would like to put the power down to minimum level which is command ATPL 0 if I am not wrong. Could this be done automatically by programming it in the setup() function without going through XCTU? if so, how would i do it? how could I send the +++ to enter command and then configure the ATPL 0 and check its been done?

Thank you very much :slight_smile:

I would like to configure my Xbee S1 (which is pluged into my arduino with a Bees Shield v2.12 from seedstudio) without having to use XCTU.

Why?

Could this be done automatically by programming it in the setup() function without going through XCTU?

Yes.

how could I send the +++ to enter command

Serial.print("+++");

Assuming that the XBee is on the serial port.

and then configure the ATPL 0

Serial.print("ATPL=0");

and check its been done?

In a while loop, while there has not been a complete response, see if there is serial data to read. If so, read it. A complete response generally ends with a carriage return and line feed.

I want to do this because I have to configure 3 arduinos and I think its faster to add a few lines of code to the setup than configuring each one individually with XCTU right?

I have a software serial library, which uses pins 8 and 9 to tx/rx. Therefore the default Serial i use to read and print info on the monitor serial screen while the SoftwareSerial mySerial i use to tx/rx data from the Xbee. If i'm not wrong there should also be a delay of 1 sec before and after the +++ correct¿? something like:
delay(1000);
mySerial.print("+++");
delay(1000);
mySerial.print("ATPL=0");
...
a while loop that waits for =="\r\n"

Thanks for your help :slight_smile:

I want to do this because I have to configure 3 arduinos and I think its faster to add a few lines of code to the setup than configuring each one individually with XCTU right?

You have to configure other things, too, right? Like MY, DL, etc.

You need to read the existing configuration, and then rewrite it, right?

You need to perform error checking on the parameter and value, right?

I think that using X-CTU will be easier. But, that might be just me.

If i'm not wrong there should also be a delay of 1 sec before and after the +++ correct¿?

If the XBee doesn't receive a command every second or less while in command mode it exits command mode. So, a one second delay after entering command mode hardly seems like a good idea. The delay before entering command mode is plain useless. It simply wastes a second.

XBees can also be configured by connecting them to a terminal program and issuing the required AT commands. Set the desired parameters, then issue the ATWR command to save them to non-volatile memory. Personally I prefer X-CTU but whatever floats your boat.