Let's Make Robots!

XBee AT/API Reliability

Hi all, I'm trying to control 4 servos with 4 pot via xbee, setup as follows:

Tx: Arduino connected to 4 pots(pins 0-3) & XBee (Series 2.5)

Rx: Arduino connected to 4 servos (pins 5, 6, 10, 11) & XBee (Series 2.5)

The Tx side will map the pot values (0-180) and send them over to Rx.


I've setup the XBees in AT Mode using guibot's tutorial but the order of the 4 values @ the Rx end jumbles up at times.

Thus, I'm trying out the API mode with the Xbee library but with no success.

I've tested the Series2_Tx & Series2_Rx examples in the library but I'm getting 2 flash on the led, which translates to:

// local XBee did not provide a timely TX Status Response -- should not happen


Is AT mode sufficient for what I'm attempting? How should I go about with the API mode?



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

When I was setting my Xbee's up for wireless program uploads I also had some troubles with data scrambling. Something you might want to check on is your computers port settings. Try reducing the latency timer in the advanced options.

You might want to use Serial.available() to check if your buffer is overflowing.


Here you go:



const int startByte = 199;
const int endByte = 250;

int data1, data2, data3, data4;

void setup(){

void loop(){
  data1 = analogRead(0);
  data2 = analogRead(1);
  data3 = analogRead(2);
  data4 = analogRead(3);
  data1 = map(data1, 0, 1023, 0, 180);
  data2 = map(data2, 0, 1023, 0, 180);
  data3 = map(data3, 0, 1023, 0, 180);
  data4 = map(data4, 0, 1023, 0, 180);

  Serial.print(startByte, BYTE);            //Initiate
  Serial.print(data1, BYTE);
  Serial.print(data2, BYTE);
  Serial.print(data3, BYTE);
  Serial.print(data4, BYTE);
  Serial.print(endByte, BYTE);              //End



#include <Servo.h>

Servo servo1, servo2, servo3, servo4;

byte rx, data1, data2, data3, data4;

const int startByte = 199;
const int endByte = 250;
const int error = 255;

void setup(){


void loop(){
  if (Serial.available()){
    rx = Serial.read();
    delay(6);                  //needed for code to work
    if (int(rx) == startByte){
      data1 = Serial.read();
      data2 = Serial.read();
      data3 = Serial.read();
      data4 = Serial.read();
      rx = Serial.read();
      if(int(rx) == endByte && (int(data1) != error ||
                                  int(data2) != error ||
                                  int(data3) != error ||
                                  int(data4) != error)){



do you have the code for what you are doing?

I know this is the forum for discussing your problem with the xbee's but i would be very interested in seeing your code

I've restored the XBees to factory setting & same thing;

w/o XBee, Tx led flashed at constant rate

w XBee, Tx led flashed intermittently

Are you doing anything to be sure you don't overflow on the Tx end? The baud rate at which you communicate with the xBee module is not the guaranteed baud rate that characters are delivered at. Try starting with overkill, like a delay(50) after you send each character. If that works, reduce the number until it fails again and you can determine the actual aggregate rate you are getting.

And yes, I meant full reset to "party line" mode.

I've tried delay(1000) but with same result.


How do i ensure that the Tx is not overflowing?

A delay of 1000 between each character? If you can't send one character per second at close range using factory defaults then one of your xBee units is bad. You should see a a data rate of over 500 characters per second even at medium range.

But just to make sure - your diagnostic has to be at the send end first and needs to have e a timeout.

You're right, one or both of my XBee's is dead.


Borrowed some XBee's from my friend and it works. Now I'm trying to 'revive' my XBees.


One more problem though, I've to put the Coordinator on the Rx & the End Device on the Tx for it to work.

Switching them does not work.

I can't help you with the Coordinator and End Device issues. I wanted a more equal peer relationship, so I implemented my own protocol. An observation I can make is that your test indicates that the End Device has the correct address for the Coordinator. Other assumptions are still assumptions...

Meery Xmas!


Managed to revived one of the XBees, still working on the second one. Any help with de-bricking will be appreciated.


I thot the one of the Xbee must be set to the coordinator; the other an end device?

what kind of protocol are you using?