Go Down

Topic: Arduino Not Reading XBee Data Correctly (Read 102 times) previous topic - next topic


I am working on using two Series 2 xBee modules to communicate to each other for a quadcopter project I am working on.

One xBee is connected to my computer using an explorer dongle and is set up as a Coordinator AT. The other xBee is connected to my arduino using a sparkfun xBee shield. It is set up as an End Device AT.

Both xBees are set up to communicate at 115200 Baud Rate, and I have them communicating to each other successfully.

I have made a simple desktop application in windows to take values from a ps4 controller and send them over to the arduino using the xbees in the format <char, float, float, float, float> (each float goes to two decimal places).

Hopefully that is enough of a background into the project to get a better understanding on what the problem might be.

The issue I am having is that the data from the computer read through the arduino is not what it should be. Below is the code I am using for simple debugging for now. Eventually, I want to parse the data using Robin2's guide to look for a beginning char '<' and an end char '>'.

Code: [Select]

#include <SoftwareSerial.h>
#include <Wire.h>
#include <Servo.h>

const byte numChars = 64;
char receivedChars[numChars];

//char recvChar;
//char endMarker = '>';
boolean newData = false;
boolean checkFirstValues = false;

SoftwareSerial xBee(2, 3);
Servo myservoT;

char startChar = '<';
char endChar = '>';
boolean startBool = false;
boolean recBool = false;

void setup()

    Serial.println("<Arduino is ready>");

void loop()

void getXbeeData()
  while (xBee.available())
    static byte index = 0;
    char rc;
    rc = xBee.read();

Using the code above I get the following serial output (throughArduino.PNG) using Tera Term. The first char should have been a 'q' not a '-'. Then I get random spacing and random values that were not sent by the computer.

However, the throughXBeeDongle.png shows the serial values that were sent from the coordinator to the end device xbee, but this time, the end device xbee is using another explorer dongle and not the arduino.

This leads me to believe I am doing something wrong in my arduino code. I am not sure what I need to change so that I can read the incoming data consistently using the arduino.

If I need to include anything else that might be helpful in solving this, I will provide what I can.




The other xBee is connected to my arduino using a sparkfun xBee shield.
What Arduino are you using? SoftwareSerial is not very reliable at 115200. That is the maximum speed it can work at, but it REALLY taxes the microcontroller at that speed.

The art of getting good answers lies in asking good questions.


Paul, currently I am using an Uno. If I were to use a 32bit controller like the due or zero, would that make any difference?

Thanks for the response,


Go Up