Stumped on serial output

I have a couple XBee SMD units that I've been playing with and have run into something that I'm stumped on. I know there is a logical explanation, but darned if I'm seeing it.

When using Digi's XTCU program, I can send serial back and forth all day. No problems, but that isn't why I got them.

I tried keeping one connected to the XTCU interface, and hooked the other up to an UNO, BUT ONLY the Tx on the Xbee to the Rx on the Uno. I thought I would just try to print serial on the monitor in Arduino IDE, so basically sending serial from the XTCU Xbee to the Uno Xbee and print on the respective monitors. Well, that failed miserably, but that isn't what has me stumped. All the Arduino ide printed was a line of 0's. No data. BUT, when I typed into the Arduino IDE and hit return, it appeared on the XTCU monitor, and indicates it is from the Uno Xbee.......

How? The Rx line of the Uno Xbee (Uno Tx) isn't hooked up.

tinman13kup:
How? The Rx line of the Uno Xbee (Uno Tx) isn't hooked up.

I think you got your wiring mixed up. Can you post a pic of your wiring? Also, what type of XBees are you using? S1, S2, S2c?

Ahh, I forgot to mention everything. They are the S2C Digimesh units. As for wiring, there is only 3 wires. 2 are 5V and Gnd, and the 3rd is Uno pin 0 (Rx) to Xbee pin 4 (Tx). The other Xbee is using a USB/Serial board to the computer. There are no wires to get wrong

tinman13kup:
There are no wires to get wrong

If you have any wires (even if it's just one), then there are wires to get wrong. I will not give any further help until you post a pic of your wiring (clear image please).

That was interesting. First time I've tried doing pictures and uploading with this computer (Win10).


As I said, there are only 3 wires. The pins on my module are set as a USB/serial converter so I can simply plug one in to program it. My intended end-use only needs the rx/tx pins.

Anyways, the Uno Rx pin is easy enough to see. The others are from left to right;
gnd / CTS / 5V / Tx / Rx / DTR.

The code is rubbish, as I simply tried it off the top of my head and it compiled fine, so I loaded it. I need to improve it a bit/bunch, trial and error.

Here it is

int data;
void setup() {
  Serial.begin(9600);
  
  // put your setup code here, to run once:

}

void loop() {
  if (Serial.available() > 1) {
data = Serial.read();
    Serial.print(data);
  }
  // put your main code here, to run repeatedly:

}

Which brings me to my question; how is the Uno Tx putting out data to the Xbee to transmit? I'm guessing I have a problem with the monitor and Xbee using serial, but I wouldn't expect something like this as a result.

The real irritating part is the Xbee that is hooked up through XTCU isn't communicating with the one on the Uno. It seems to be a one way street---backwards. I will mess around more with that later

Are you using a shield or anything for the XBee? Can you post a link to where you got it online?

Also, you CAN'T use the one hardware serial UART for BOTH XBee and serial monitor stuff. Use something like softwareserial.h

Ok, so what's happening is that your wiring is wrong (that is, unless your pinout is correct, but I doubt it is) and you are abusing the hardware UART on the Arduino.

The details: when you send data to the Arduino via serial monitor, the RX data from the USB port is mirrored to the RX pin. This pin is actually connected to the Din pin of the XBee and the data is accidentally send to said XBee. The XBee then transmitts it to the other XBee which is connected to your PC. The data then shows up on the XCTU software.

Remember: Use softwareserial.h in addition to crosing RX and TX as in:

Uno - XBee
TX -> Din
RX <- Dout

Actually, it was both. The pinout is correct---for the serial converter. Swapping the wire to the Tx on the Xbee is putting out incorrect data, but it is going. The incorrect data is my code I'm figuring. I can work on that, as long as I have something to work with. The Uno is just a starting point for this. When I get a grasp on it, I will move on to a Teensy.

Thanks.