1

I have 2 Xbee Series 2 modules. One of it is connected to arduino via an adapter. And Ground 5V, as well as Rx>>Tx and Tx>>Rx.

The xbee is configured AT mode Coordinator.

I want to use the serial monitor in arduino to change the parameters of the xbee, such as DH or DL or PAN ID things like this.

Is there a way for the xbee to display its "OK" response after entering command mode on the serial monitor?

2 Answers 2

1

Because you have an Arduino Mega, you can set it up to use it like a USB-to-UART adapter by using the following code (source):

void setup() {
  // initialize both serial ports:
  Serial.begin(9600);
  Serial1.begin(9600);
}

void loop() {
  // read from port 1, send to port 0:
  if (Serial1.available()) {
    int inByte = Serial1.read();
    Serial.write(inByte); 
  }

  // read from port 0, send to port 1:
  if (Serial.available()) {
    int inByte = Serial.read();
    Serial1.write(inByte); 
  }
}

Basically what this does is it takes the data it receives from the USB port via Serial and transmits it to Serial1 and then also reads from the UART port via Serial1 and transmits it back to the computer via Serial. With this code running you should be able to hook up the XBee to RX1 and TX1 and communicate to it using the Serial Monitor.

4
  • Wow, Thank you for your response. I tried it out, it worked, but somehow it only work if i connect xbee rx to arduino rx1 and xbee tx to arduino tx1. Is this supposed to be this way. all i change is changing int inByte to char inByte Jul 18, 2015 at 7:59
  • And, i also tried using +++ to enter command mode. i can receive the first OK response, but the subsequent commands are not able to go through. thank you in advance Jul 18, 2015 at 8:14
  • It should be rx to tx in both directions. Also the baudrate in my example (9600) should be changed to match whatever your xbee is configured for.
    – Jake C
    Jul 18, 2015 at 8:22
  • THANK YOU SO MUCH, it worked as you said.. My coordinator DL is wrongly typed. Jul 18, 2015 at 9:38
0

Not if you have it connected to pins 0 and 1, no. You should not use those pins for anything unless you absolutely have to, since they are what are used for communication with the PC. You can't do both communication with the PC and with the XBee using the same pins.

You should ensure that the XBee is connected to one of the other serial ports on the Mega and then write a sketch that passes the data through from one port to the other as needed so you can view it on the serial monitor.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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