Using XBee and USB cable at the same time.

Hello,

I'm trying to Serial.print to an XBee and through a USB cable to a computer at the same time. My setup is XBee ---> Parallax XBee USB Adapter Board ---> Computer on one end, and on the other I have an Arduino connected to a USB cable, and also connected to Parallax XBee 5V/3.3V Adapter Board to another XBee.

The code that's loaded on the Arduino just reads serial in, and prints it back out when it gets it. When I send a byte from the XCTU software, I've verified that the transmitting XBee sends the data, and I can see that the receiving XBee receives the data. The problem is that the character doesn't show up in the Serial Monitor for the Arduino. Since the USB cable is connected to the Arduino, when it recieves the data from the XBee, I would expect it to send the data back out over the XBee and over the USB cable. Is it not possible to receive data from an XBee while a USB cable is hooked up?

Thanks,

Waruma

Do you have a link to the Parallax XBee adapter board?

Some XBee shields have jumpers that allow the serial pins to talk to the XBee OR to the USB chip.

Yes, here's the links. I didn't notice any jumpers on them when I was hooking them up.

On the computer end, I'm using this USB adapter board: http://www.parallax.com/StoreSearchResults/tabid/768/List/0/SortField/4/ProductID/643/Default.aspx?txtSearch=XBee+adapter+board

And on the Arduino end, I'm using this level converter adapter board: http://www.parallax.com/StoreSearchResults/tabid/768/List/0/SortField/4/ProductID/664/Default.aspx?txtSearch=XBee+adapter+board

And with the Arduino code, if I enter characters into the Serial Monitor of the Arduino, it will transmit them to the Computer XBee. I just can't transmit from the XCTU through the Arduino and loop it back to the XCTU.

Thanks,

Waruma

I just can't transmit from the XCTU through the Arduino and loop it back to the XCTU.

Semantics, maybe, but XCTU doesn't talk to the Arduino. It talks to the first device you listed, which talks to the mounted XBee which broadcasts the data.

When you enter data in X-CTU, does the TX light on the first device blink?

The XBee that receives the data is the one on the device attached to the Arduino. Does the RX light on that device blink? Does the RX light on the Arduino blink when the XBee on the attached devices sends data to the Arduino?

What code is running on the Arduino? Does the TX light on the Arduino blink when it sends a reply? Does the TX light on the XBee device blink when the Arduino sends it data to broadcast?

Does the RX light on the device attached to the PC blink when that XBee receives data?

What kind of XBees are they - series 1 or series 2/2.5? How are they configured?

All these questions are designed to determine where the data is getting lost.

I realize the XCTU doesn't talk to the Arduino. The XBees are both basically out of the box - and they're series 1 XBees. I've gone through the XCTU maual to learn about all the advanced setup options and configuration options of an XBee, but I have reset them both to their original configurations and verified that they communicate with each other.

When data gets sent out of the XCTU terminal, the Tx light on the Tx XBee (attached to computer) lights up, and the Rx light on the Rx XBee (attached to Arduino) also lights up. When this happens, the data does not get echoed back to either the Serial Monitor screen, or the Tx line of the Rx XBee. The only way I can send data back to the Tx XBee is if I type characters into the Serial Monitor - the Rx XBee will then transmitt those to the Tx XBee at the computer. When I do it this way, the Tx light on the Rx XBee lights up, and the Rx light on the Tx XBee lights up as well. I've probed all of these Tx and Rx lines with an Oscope to make sure the radios are transmitting and receiving data. I haven't explicitly looked to see if the Tx and Rx lights on the Arduino light up, but I can check that when I get home.

For some reason though, the data doesn't seem to be making it from the Rx line on the Arduino, to the Serial Monitor, and back out to the Tx line. I think there might be a conflict between the XBee and the USB cable both trying to have access to the Tx, Rx lines of the Arduino. Can anyone confirm or deny this statement?

Here is the code I have running on the Arduino: // int incomingByte = 0; // for incoming serial data

void setup() { Serial.begin(9600); // opens serial port, sets data rate to 9600 bps }

void loop() {

// send data only when you receive data: if (Serial.available() > 0) { // read the incoming byte: incomingByte = Serial.read();

// say what you got: Serial.print("I received: "); Serial.println(incomingByte, DEC); } }

Does anyone have an answer to this problem? I would greatly appreciate some insight as to why this isn't working? Can other people receive from an XBee and both transmit back [u]and[/u] print to the serial monitor?

I managed to get my system working by creating a software serial port on pins 2 and 3 and then transmitting the recieved character back over XBee communications, and serial.print() to pin 1 to get that to show up on the serial monitor. I just don't think I should have to do it this way. This seems like it's too complicated of a solution.

Can other people receive from an XBee and both transmit back and print to the serial monitor?

Yes. But, not using the same hardware you are using.

but I have reset them both to their original configurations and verified that they communicate with each other.

I don't understand this. Out of the box, two XBees won't talk to each other, in spite of the BS on digi's site. The PAN IDs will match, but each has the same MY and DL address, so they won't talk to each other. MY on one has to match DL on the other in order for communications to work.

I managed to get my system working by creating a software serial port on pins 2 and 3 and then transmitting the recieved character back over XBee communications, and serial.print() to pin 1 to get that to show up on the serial monitor. I just don't think I should have to do it this way. This seems like it's too complicated of a solution.

Hey, whatever works is good.

I exclusively use series 2 XBees so I don't have anything definitive on the series 1 for you, but I have never, ever made the XBee work reliably connected to the usart ports at the same time I'm using the USB port. Tried it a couple of times and there were so many complications I just gave it up forever. I do what you did. I create a softwareSerial port on two different digital pins and transfer between this and the usart port (digital 0 and 1).

If you only use pins 0 and 1 for the XBee and disconnect the USB it will work fine; just never worked at the same time as the USB for me.

Oh, I don't have any problem with the series 2 devices working the first time I power them up. That is, if I already have a coordinator running somewhere. The XBee comes configured as a router with DL set to broadcast and it finds the coordinator and just starts working. However, if I reprogram it, all bets are off. About 80% of the time the darn things have some problem or other during programming and I lose various items that have to be programmed back. Now, if I try to bring two of them up and no coordinator already running, they can't talk since there is no coordinator (new ones always arrive as routers). One of them has to be set up as a coordinator before there's any hope of them working. For that very reason, my coordinator is in a device that has almost nothing to do. It just serves as the house coordinator and a simple clock. That way I always have a coordinator on line.

Net, the solution you arrived at is almost exactly the same one that I arrived at. Good job.

Thank you both for the replies. I just wanted confirmation that someone else somewhere out there was having the same problems as me. Creating a software serial port was the only readily available solution with the Arduino knowledge I have.

PaulS - to clarify, the XBee are supposed to work for basic serial communications right out of the box. It says so on Digi's website I believe - or in their users manual or something. If the MY and DL addresses are the same on each of the XBees, doesn't that mean they'll transmit to and receive from all XBees within range? I was under the impression that this was the case, and you could specify those addresses if desired...

Thanks again for everyone's help.

The MY address defines the XBee's handle. The DL address defines specifically which other XBee to talk to. Unless random values are assigned at the factory, and you get extremely luck, you need to change the values of MY and DL on one XBee to match the values of DL and MY on the other XBee. That is configuring the XBees in my book, and is something that digi says is not needed. Bullshit.

Working from memory here, so take it for what it's worth. The DH, DL address is factory set for broadcast when shipped. That means everything talks to everything in peer to peer mode. That should make them talk, but not efficiently. This doesn't mean that someone in the supply chain set up a test bed that changed the devices before you got them. Once again, I have zero experience with Series 1, but that's what I've read people's experiences have been. If you already have a couple of them running in the house in some other mode, there may be problems. Series 2 will work out of the box if there is already a coordinator running. If there isn't you gotta make one, then they work.

Okay - so since I currently only have 2 Series 1 XBees in my house, that's probably why they aren't conflicting with anything else. When I get more, it sounds like I am going to have to pay attention to the MY and DL settings of each XBee to get them to talk properly.