Arduino to Computer Using XBee

I am trying to replace an annoying USB Connection from my main computer to an Arduino Mega 2560 with a wireless connection. Basically, I want it be able to operate my Arduino Mega through the Serial Monitor in exactly the same way as how you would do it with a USB Connection, only that I want it wireless instead.

I currently have two XBee Modules, one fitted to a Sparkfun XBee Explorer USB and the other fitted to a UART SBee. At first, I connected these two modules to two different desktop computers and used a program called X-CTU to configure them. Eventually, I was able to get the two modules to communicate wirelessly with each other through the X-CTU Terminal.

My next plan was then to connect one of these module to an Arduino and reattempt the process. Common sense told me that I should connect the UART SBee to the Arduino since it has the Tx/Rx pins. I connected the Rx/Tx pins to pins 0 and 1 of the Arduino Mega, using the usual law of connecting Rx to Tx and vice versa. I also power up my Xbee by using the output power pins from the Arduino Mega. As a test sample, I pre-uploaded a program to my Mega that echos back whatever you type into the Serial Monitor command line.

In the meantime, my Explorer USB Shield was connected directly to the second desktop computer through a USB Connection, where I open Serial Monitor on that computer for interfacing.

Unfortunately, this is where all the disappointment came in. I could not get any communication happening between the Arduino Mega 2560 and the second main computer. When I type something, I get nothing coming back at me.

Another discovery that I found was that when I try to send characters through a USB Connection to the UART SBee directly to the Arduino from my first main computer. I find by doing this, the characters that I send will get sent to both the explorer USB (And hence the second main computer) and the Arduino Mega at the same time. The Arduino Mega will also echo the characters back to my first main computer through that USB connection, BUT I do not pick up anything on the second computer! It seems when I use Serial.print on the Arduino Mega, it can send the stuff through the USB port on my UART SBee, but can't send anything through the XBee.

Could anyone please help identify the problem and why my Arduino Mega can't send anything to my second computer through the XBee wireless connection??

Could anyone please help identify the problem and why my Arduino Mega can't send anything to my second computer through the XBee wireless connection??

None of your links worked. That's you first problem.

None of your code showed. That's your second problem.

Connecting the XBee and the PC to the same serial port is going to cause confusion and grief. That's your third problem.

You've said nothing about the XBees - type, configuration, etc. That's your 4th problem.

Solutions? None until you provide more information.

PaulS:
None of your links worked. That's you first problem.

None of your code showed. That's your second problem.

Connecting the XBee and the PC to the same serial port is going to cause confusion and grief. That's your third problem.

You've said nothing about the XBees - type, configuration, etc. That's your 4th problem.

Solutions? None until you provide more information.

Problem 1: What links?

Problem 2:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

// From Serial Monitor
char* CollectStr_SM(char* OriginalStr) {
  char c ;  
  int i = 0 ; 
  free(OriginalStr) ; // Delete Old Memory Data
  OriginalStr = (char*) malloc(sizeof(c)) ; 
  while (Serial.available() > 0) {
    delay(5) ; // Delay a short time for incoming characters to arrive
    c = Serial.read() ; 
    // Assign Character to Original Str
    OriginalStr = (char*)realloc(OriginalStr, sizeof(c)*(i+2)) ; // Add a Character Memory Slot
    OriginalStr[i] = c ;  // Assign the Character
    i = i + 1 ; 
  }
  OriginalStr[i] = 0 ; // Add the \0 String End Indicator Character
  return OriginalStr ;
}

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

void loop() {
  // Collect the String Data, then print it back to the Serial Monitor
  if (Serial.available() > 0) {
    char* Str ; 
    Str = CollectStr_SM(Str) ;
    Serial.print("You Typed: ") ; 
    Serial.println(Str) ;  
  }
}

This source code is what I'm using to test the connection of my Arduino Mega 2560.

Problems 3: Are you referring to the part where I connected a USB cable to the UART SBee while having that Arduino Mega connected at the same time?

Let me re-establish my proposed electrical connections a bit more clearly. What I intend to do is:

On one end, I have a Arduino Mega 2560 connected to the XBee XSC mounted onto a UART SBee. There is NO USB Connection involved on this end. Since this is the case, I assume it is ok to just directly connect my UART SBEE to the default Serial pin 0 and 1 and use the usual Serial.print/Serial.read functions. As I mentioned in my original post, before connecting my XBee, I uploaded my source code to the Mega 2560 through the usual direct USB connection.

On the other end, I have another XBee XSC mounted on a Sparkfun USB Explorer Shield. The Sparkfun USB Explorer Shield is then connected directly to a main computer. There is no Arduino connected on this end, so there is no source code needed here. At least that's what I think.

If my explanation is still not clear enough, take a look at this image:

What I was trying to say in my original post was that IF I connect a USB to my UART SBEE (Which is in turn connected to the Mega), then I have no issues communicating between my Mega and my main computer through the USB connection. However, as soon as I remove that USB connection, then try to communicate to my Arduino from the other computer (Via the Xbee wireless connection), I get nothing. I find this very strange, considering the fact that I had no issues communicating between the two main computers via the X-CTU terminal if I connected them directly with the XBee.

Problems 4: My two XBee Modules are both model XBP-09 XSC. I used X-CTU to configure both their "Network Address" 9999 and my Mask Address at FFFF. Please let me know if there is anything other software config info that you need to know. These two XBee Modules are mounted on two different XBee Shields, and I already mentioned in my original post what they were.

Having the antennas that close could cause some data transfer issues. Make use they are at least a good hands length away. Other than that, I wouldn't know. Hope you get it working.

I only put them that close so that I could take a single clear photo shot of the whole assembly. No testing was done at this distance. When I actually tested them, they were about 5 meters away from each other.