Go Down

Topic: XBee and RX0 (Read 698 times) previous topic - next topic

kkessler

I have a project where I'm collecting data through a bunch of sensors, storing it on an SD card, and want to send a command through XBee to the Arduino Uno and have it download the data (http://kesslerarduino.wordpress.com/ in case you are interested).  Some of the sensors use FreqCounter to measure frequency, which uses the T1 interrupt, and that makes using the NewSoftSerial library impossible to use (I can get everything to work with NewSoftSerial, if I'm not actually hooking onto the interrupt to count frequencies).  I read about the XBee Shield in the playground section, and it says that hooking it up in "XBee" mode make it no longer able to receive serial input from the USB cable (which would be fine with me), and only be able to receive input from the XBee.  If I connect my XBee to TX0/RX0, output from the Arduino comes through both the USB "Serial" cable and the XBee serial cable, but I can only send to the Arduino through the USB serial; communication in the outgoing direction through the XBee doesn't make it to the Arduino ( although I can see the correct LEDs flashing on the Parallax SIP Adapter which connects the XBee to the Arduino, so I know the XBee is seeing my request).  Basically, it looks like my situation is opposite the XBee Shield; I can only receive data in the Arduino through the USB cable no matter what happens on the XBee, even though, looking at the schematic of the XBee Shield, I don't see that they are doing anything different than connecting to the TX0/RX0 pins, which is what I'm doing.  

As another test, I used an Arduino Mega, which has 4 UARTS, and hooked the XBee to TX1/RX1, and the following code works fine:
Code: [Select]

char buffer[101];
int bufIdx=0;

void setup()
{
 Serial1.begin(9600);
 Serial1.println("Hello");
}

void loop()
{
   checkSerial();
   delay(1000);
   Serial1.println("Foo");
}

void checkSerial()
{

 while (Serial1.available())
 {
     Serial1.println("Available");
     char inByte=Serial1.read();
     Serial1.print(inByte);
     if((inByte==13)||(inByte==10))
     {
       buffer[bufIdx]='\0';
       
       if(strcmp(buffer,"*COPY")==0)
       {
         Serial1.println("Copy");
       }
               
       bufIdx=0;
     }
     else
     {
       buffer[bufIdx++]=inByte;
       if(bufIdx==100)
         bufIdx=0;
     }
 }
}


If I put the XBee on RX0/TX0 of the Mega, though, and change all the above Serial1's to Serial's, it doesn't work.

Is what I'm trying to do impossible, or is there some way to get the Arduino to accept communication through the RX0 pin on something other than the USB FTDI connection ?

Go Up