Arduino to Arduino Xbee Communication issues

General project help for Adafruit customers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
Aluman000
 
Posts: 27
Joined: Sun Apr 10, 2011 4:27 pm

Arduino to Arduino Xbee Communication issues

Post by Aluman000 »

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

#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

#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

Post by Aluman000 »

Any Thoughts? Got both the Xbees and adapters here.

User avatar
adafruit_support_bill
 
Posts: 88088
Joined: Sat Feb 07, 2009 10:11 am

Re: Arduino to Arduino Xbee Communication issues

Post by adafruit_support_bill »

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

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

Re: Arduino to Arduino Xbee Communication issues

Post by Aluman000 »

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?

User avatar
adafruit_support_bill
 
Posts: 88088
Joined: Sat Feb 07, 2009 10:11 am

Re: Arduino to Arduino Xbee Communication issues

Post by adafruit_support_bill »

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.

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

Re: Arduino to Arduino Xbee Communication issues

Post by Aluman000 »

Yep!

I dropped the baud to 4800 and it works perfectly.

perhaps I'll leave buffer management for another day.

Thanks.

Locked
Please be positive and constructive with your questions and comments.

Return to “General Project help”