Arduino to Arduino Xbee Communication issues
Moderators: adafruit_support_bill, adafruit

Arduino to Arduino Xbee Communication issues

by Aluman000 on Sat Dec 01, 2012 1:42 pm

Ok,

Background:
I have successfully gotten communication between 2 Unos using Software Serial working.
My sending station sends the numbers 1 to 100 repeating to the receiving station which outputs it to the serial monitor.

Here's my next challenge: I want to replace this direct connection with 2 Xbees.

In each case I have the Xbees and Uno's connected with 3 wires.
The sending station has 1 Gnd to Gnd, 1 5V to 5V, and 1 from Pin 3 to Rx on the Xbee.
The green light is flashing.

The receiving station has 1Gnd to Gnd, 1 5v to 5V and 1 from Pin 2 to Tx on the Xbee.
The green light is flashing and the red light is lit constantly.

My code for both stations is this:
SENDING
Code: Select all | TOGGLE FULL SIZE
#include <SoftwareSerial.h>

SoftwareSerial Xbee(2,3);

int i;

void setup()
{
  Serial.begin(57600);
  Xbee.begin(57600); 
} // Setup

void loop()
{
 
   
  for ( i = 1; i <= 100; i++)
  {
   
   Xbee.print(i);
   Xbee.print('T');
   Serial.println(i);
   
   delay(500);
   
  }
 
} // Loop


RECEIVING
Code: Select all | TOGGLE FULL SIZE
#include <SoftwareSerial.h>

SoftwareSerial Xbee(2,3);

int RecVar;
int input;

void setup()
{
  Serial.begin(57600);
  Xbee.begin(57600); 
} // Setup

void loop()
{
//  delay(50);
   
  if(Xbee.available())
  {
   
    RecVar = Xbee.read();
    //Serial.println(RecVar); //Troubleshooting step
    if(isDigit(RecVar))
     {
       input = (input * 10) + (RecVar - 48);
     }
    else
    {
      Serial.println(input);
      input = 0;
    }
   
  }
 
} // Loop


So when Directly Connected (1wire pin 3 to pin 2, 1 wire GND to GND) I get this:
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
...


But when put through the Xbees I get:
2
3
4
5
6
8
9
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
2
0
2
0
2
0


What's the Xbee Doing?
Aluman000
 
Posts: 27
Joined: Sun Apr 10, 2011 4:27 pm

Re: Arduino to Arduino Xbee Communication issues

by Aluman000 on Sun Dec 02, 2012 3:22 pm

Any Thoughts? Got both the Xbees and adapters here.
Aluman000
 
Posts: 27
Joined: Sun Apr 10, 2011 4:27 pm

Re: Arduino to Arduino Xbee Communication issues

by adafruit_support_bill on Sun Dec 02, 2012 3:26 pm

Still thinking. Not quire sure what is going on there. Have you posted this over at the DIgi forum? They might have a better idea of what is happening.
forums.digi.com
User avatar
adafruit_support_bill
 
Posts: 31071
Joined: Sat Feb 07, 2009 10:11 am

Re: Arduino to Arduino Xbee Communication issues

by Aluman000 on Wed Dec 05, 2012 8:53 am

Guy on the Arduino forum seems to think this has something to do with the baud rate filling up the Xbee buffer.

Do you know anything about the Buffer size or how to manage it?
Aluman000
 
Posts: 27
Joined: Sun Apr 10, 2011 4:27 pm

Re: Arduino to Arduino Xbee Communication issues

by adafruit_support_bill on Wed Dec 05, 2012 9:30 am

The buffer is whare the XBee stores data waiting to be transmitted. If you send it data faster than it can transmit, the buffer will overflow.
The Arduino libraries don't support flow control. You can try just using a lower baud rate - e.g. 9600.
User avatar
adafruit_support_bill
 
Posts: 31071
Joined: Sat Feb 07, 2009 10:11 am

Re: Arduino to Arduino Xbee Communication issues

by Aluman000 on Wed Dec 05, 2012 6:54 pm

Yep!

I dropped the baud to 4800 and it works perfectly.

perhaps I'll leave buffer management for another day.

Thanks.
Aluman000
 
Posts: 27
Joined: Sun Apr 10, 2011 4:27 pm