1

I have two XBee Pro S2Bs: one is plugged in to a USB explorer, and; the other is plugged into an Arduino Wireless Protoshield, which is connected to an Arduino Uno.

My XBee connected to the explorer is configured as the coordinator in AT mode, and the XBee connected to the Arduino is configured as a router in AT mode. As a side note, I tested the network with a second USB explorer, and I was able to communicate between both XBees.

I uploaded the following code to the Arduino (which is just a sample I pulled off the internet somewhere):

char rx_byte;

void setup()
{
    Serial.begin(9600);
}

void loop()
{
    if (Serial.available() > 0)
    {
        rx_byte = Serial.read();
        Serial.print("You Typed: ");
        Serial.println(rx_byte);
    }
}

Once I upload the code and turn on the serial monitor for the Arduino (using either the Arduino IDE or Visual Micro, with the Arduino plugged in via USB), and turn on the serial monitor on for the XBee connected to the USB explorer (using the serial monitor in XCTU), I get the following results:

  • If the wireless proto shield has its switch set to USB mode, then I can send data from the Arduino serial monitor to the serial monitor in XCTU, but the Arduino serial monitor doesn't receive data that is typed into the XCTU serial monitor.

  • If the wireless proto shield has its switch set to Micro mode, then I get mostly the opposite result. I can send data from XCTU serial monitor to the Arduino serial monitor, which the result is returned to the XCTU serial monitor, e.g., if I type "X" in XCTU serial monitor, both serial monitors say "You Typed: X". However, if I try to send data through the Arduino's serial monitor, neither serial monitor displays anything.

What I would like to do is be able to type in either serial monitor and have the data displayed in both serial monitors, like you would expect in a simple chat program.

Can someone see where I have gone wrong and/or how to get to the correct result?

1 Answer 1

2

Check out https://learn.sparkfun.com/tutorials/xbee-shield-hookup-guide/example-communication-test Essentially you need to set up Software Serial for your xbee to communicate on a couple of digital pins, instead of using hardware serial. When using hardware serial (the RX and TX pins) only one device works on it at a time, hence why you can't use the xbee and the serial monitor at the same time.

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.