Arduino to Arduino Xbee Communication issues

General project help for Adafruit customers

Moderators: adafruit_support_bill, adafruit

Arduino to Arduino Xbee Communication issues

Postby Aluman000 » Sat Dec 01, 2012 12: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
#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 3:27 pm

Re: Arduino to Arduino Xbee Communication issues

Postby Aluman000 » Sun Dec 02, 2012 2:22 pm

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

Re: Arduino to Arduino Xbee Communication issues

Postby adafruit_support_bill » Sun Dec 02, 2012 2: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: 16022
Joined: Sat Feb 07, 2009 9:11 am

Re: Arduino to Arduino Xbee Communication issues

Postby Aluman000 » Wed Dec 05, 2012 7: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 3:27 pm

Re: Arduino to Arduino Xbee Communication issues

Postby adafruit_support_bill » Wed Dec 05, 2012 8: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: 16022
Joined: Sat Feb 07, 2009 9:11 am

Re: Arduino to Arduino Xbee Communication issues

Postby Aluman000 » Wed Dec 05, 2012 5: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 3:27 pm


Return to General Project help

Who is online

Users browsing this forum: Exabot [Bot], OkumaCadet and 15 guests

Stuff to buy from the Adafruit store and links to product documentation!


New Products [102]

Raspberry Pi[80]
 
FLORA[23]
 
Bunnie Studios[9]
 
FPGA[1]
 
mbed[11]
Arduino[60]
 
NETduino[14]
 
BeagleBone[24]
 
Android[6]
 
XBee[10]
More Dev Boards[30]


 
BoArduino[8]
 
SpokePOV[4]
 
TV-B-Gone[4]
 
MiniPOV[3]
 
SIM reader[3]
 
Microtouch[5]
 
Clocks & Watches[18]
 
Drawdio[4]
 
Brain Machine[1]
 
Game of Life[2]
 
MintyBoost[2]
More DIY Kits[16]


 
MaKey MaKey[3]
 
Tweet-a-Watt[5]
 
Young Engineers[33]
 
Discover Electronics[2]
 
Snap Circuits[4]
 
littleBits[3]
 
Project packs[8]


 
Breakout Boards[33]
LCDs & Displays[48]
Components & Parts[69]
Batteries & Power[49]
EL Wire/Tape/Panel[52]
LEDs[109]
 
Wireless[14]
Cables[60]
 
Lasers[6]
Sensors/Parts[145]
 
Enclosures/Cases[11]
 
Solar[11]
 
RFID / NFC[13]
Prototyping[70]
 
iDevices[13]
Tools[71]
 
Wearables[39]
 
CNC[37]
 
Robotics[29]
 
3D printing[1]
 
Materials[24]


 
Stickers[41]
 
Skill badges[55]
 
Books[25]
 
Circuit Playground[7]
 
Gift Certificates[4]