My favorites | Sign in
Project Home Downloads Wiki Issues Source

ArduPlane Instruction

June 2013 UPDATE: The ArduPilot manual has now moved here. The manuals here are for legacy hardware and will no longer be updated or maintained.


en, zh-Hans , zh-Hant
Updated Nov 22, 2012 by

Using Xbee radios for telemetry with APM 2

Hooking up your Xbee wireless modules

Adding wireless telemetry is not difficult and can extend the capabilities of your UAV immensely. We recommend 900Mhz Xbees. If you are in Europe, where 900Mhz is not allowed, you can use a 2.4Ghz Xbee kit instead. Instructions for that are here.

IMPORTANT: On APM 2, you cannot use the Xbee while your APM board is connected to the USB port. That's because the Xbee and USB share the same serial port, with some clever multiplexing to detect if the USB cable is plugged in and switching output to the USB if so. Although that has the huge win of freeing up a serial port for some other use (want to connect an Android phone, anyone?), it does mean that you need to disconnect the board from the USB cable and power it some other way when testing wireless telemetry on your bench.

Wiring it up

APM 2.0

Connect the XtremeBee adapter (with the Xbee plugged in) to APM 2 as shown above. Your adapter should be in "Master" mode. ("Master" and "Slave" just reverse the TX and RX pins).

We recommend the 3DR four-wire Xbee cable, which comes with the official Wireless Telemetry kit shown above. It is designed to connect the XtreamBee adapter to APM, as it will provide the neatest and safest connection.

APM 2.5

On APM 2.5, use the dedicated telemetry port and supplied cable, as shown:

On the ground side

If you're using a USB adapter, simply connect it via a USB cable as shown:

If you're using an XtreamBee adapter on the ground side, connect it to a FTDI cable as shown below and plug that into your USB port. The adapter should also be in Master mode.

Now you're done! Remember to select the right Xbee port (you can see which one has been assigned to the Xbee in the Windows Control Panel device manager) and a baud rate of 57k in the Mission Planner or other GCS when you're connecting.

(Optional) Changing your telemetry to use UART2 (aka Serial3)

By default an Xbee connected to the APM2 will use UART0 (aka "Serial" in Arduino) which is shared with the USB as mentioned above. If you wish to instead use UART2 (aka "Serial3") for telemetry you can change the "AutoMUX UART0" jumper on the bottom of the APM2.

Although difficult to see, by default there are two small jumpers between the upper pads that must be cut with an X-Acto blade. Then a new solder bridge must be made to join the bottom pads.

(Optional) Rolling your own Xbee telemetry setup

You can make your own telemetry kit if you'd like. The first thing to keep in mind is that you should use Xbee modules in a different frequency range than your RC equipment.

In general, we recommend 900Mhz Xbee modules, but in some countries 900Mhz is not approved. In those cases you can use 2.4Ghz Xbee modules. In that configuration, we use these Xbee Pro wireless modules. Setup can be a little tricky, so please see the comments below in this manual to see how other people have done it. In particular, we do not recommend the DIY Drones XtreamBee adapter for those modules. Instead, try the Adafruit or Sparkfun adapters. Please note that the DIY Drones team will only support the recommended 900Mhz Xbee modules, so if you use something else please turn the community for help, not the DIY Drones developers.

Here is more discussion on how to pick the best frequencies for your setup.

All Xbee modules need adapters to work with APM. You have two choices:

Setting up the Xbee modules

If you have the DIY Drones Telemetry Kit, your Xbee modules are already set up and ready to go. But if you're setting up your own, here are some instructions:

The Xbee modules ship with a default of 9600bps, which you must change to match the APM's serial speed of 57600 bps; set your Xbee modules to match this speed. (If you want to use a different speed, you can change that by entering the line #define SERIAL3_BAUD [whatever baud rate you want] in the APM_Config.h file.)

Connect each one of the them to the USB adapter board, plug the USB cable into your PC, and use Digi's X-CTU utility (Mac/Linux users see section below on an alternative utility from motosenso) to select the right serial port and communicate with them. Remember to initially set the utility to 9600bps to contact the new Xbee modules, and than after you've changed the speed, change the utility's serial speed accordingly. You should also give the modules unique Network IDs (VIDs) so they will be paired. Just use any 3-digit number, and just make sure you have set it the same on both modules. (Note: If you will be flying near other UAV planes make sure to verify the Network IDs are unique and not used by others in your vicinity.)

This is what the setting should look like when you click "Read" in Modem Configuration tab of X-CTU (we're using 999 as the VID here as an example, and I've highlighted the correct baud rate):

Note: If you bought your Xbee modules from Sparkfun, rather than the official DIY Drones kit, please note that they sometimes ship with the wrong firmware. X-CTU may try to download new code, which will probably fail (cancel it). If your Xbee module is reporting that it's an XBP09-DM (rather than the correct XBP09-DP), do the following:

  1. If you have the XBP09-DP modules, you must download XBP09-DP firmware. If you have downloaded XBP09-DM firmware, it will kind-of work, but will fail at the PID-config screen.
  2. X-CTU will report the module as XBP09-DM. Ignore that. Go to the Modem Configuration tab and do the following:
    1. Select Modem as XBP09-DP, Function Set XBEE-PRO 900, Version 1002. It is important that you select 1002. Version 1061 does not work at first.
    2. Click the Show Defaults button under the Parameter View.
    3. Click the Write button under "Modem Parameters and Firmware".
    4. Go back to PC Settings, change Baud to 9600. Click Query. It will show XBP09-DM. Ignore that.
    5. Go back to Modem Configuration. Click Read. It should show XBP09-DP as the modem. Version 1002.
    6. Now select Version 1061.
    7. Click "Show Defaults"
    8. Click on the DD parameter and set it to 0. This step is important, otherwise the 1161 firmware download will fail.
    9. Click "Write". Now your firmware is XBP09-DP Version 1161.
  3. Now change the baud rate and Modem VID, redownload and you should be good to go.

It will still show XBP09-DM in the PC Settings Query. Don't worry about that.

For Non-PC users

MacOS, Linux or Windows users - there is a free cross-platform alternative to X-CTU, called moltosenso Network Manager. Download the software here. The moltosenso Team collaborated with us writing a special tutorial on the setup of Xbee radios for ARDUPILOT and ARDUCOPTER Temetry using their software. Enjoy!

Testing the connection

If you open up a terminal program on your laptop (you can use the Arduino IDE's serial monitor for this, too), select the correct serial port, and set the baud rate to whatever you set the Xbee modules to above (the default is 57600). Once you do this, you should see APM telemetry coming in. Anytime there is a "Serial3.println" in the code, that data will be sent through the Xbees to the ground. You can record any data you want, and even datalog from the ground! You can also open the Ground Station software, setting the right port and baud speed) and it should begin to show APM data.

Additionally, if you want to test the range of your Xbee link, connect the plane-side Xbee module's RX and TX pins together to create a loopback circuit and use the X-CTU utility's range test function. For the modules we are using you should get around a mile.

Note: If you've got an Xbee attached to your APM, the USB cable will probably not provide enough power by itself to drive them both. Please also have an ESC and LiPo connected to the RC pins to provide additional power. (You can tell that you've got a low power ("brownout") condition if you just have the red C LED blinking dimly, or the APM board is otherwise intermittent.)

Test code

ArduPilot Mega has four serial ports so all the usual Arduino serial commands now take a specifier to say which port you want to read from or write to. For example: Serial1.print(), Serial2.print(). The port connected to the USB/FDTI connector is Serial0. The port connected to the Telecom pins is Serial3.

Here's a quick demo that will print to all four ports so you can check to see that your Xbee connection is working. Here are the instructions on how to use it:

1) Plug your Xbee into one USB port and your APM into another. Use Arduino to load the demo code, and then in the Arduino IDE set the serial port to the one assigned to your APM board. Then open the serial monitor, setting the baud rate to 115200. You should see "Port 0" repeated as follows, showing the output from the APM's USB port:

2) Now switch the serial port to the one your Xbee is assigned to and reopen the serial monitor, setting the baud rate to 57600 (which is the speed your Xbees should already be programmed for). You should now see "Port 3" repeated, showing the output from APM's Xbee port:

Unbricking an Xbee

IMPORTANT NOTE: Sometimes Xbee modules get corrupted due to spurious signals. If you're finding that yours stops working (green LED on Adafruit adapter doesn't come on), instructions to reload the firmware follow:

Using the USB adapter board:

  1. Take the module out of the interface board.
  2. Connect the interface board to the computer.
  3. Open X-CTU make sure Baud Rate is set to 9600
  4. Go to "Modem Configuration"
  5. Put a check in the "Always update firmware" box
  6. Select proper modem from drop down menu (for the 900Mhz ones recommended above select "XBP09-DP"; for 2.4GHZ Xeebee Pro 2 select "XBP24-B")
  7. Click on the "Write" button. After a few seconds of trying to read the modem, you will get an Info box that says Action Needed. At this point, CAREFULLY insert the module into the interface board. After a few seconds, this should trigger a reloading of the firmware.
  8. You may get the info box again a short while after; if so just repeat the previous step a few times and it should work.
  9. This will put the module back to 9600 baud. Set your X-CTU PC settings to that and test it. It should report back that it's recognized.
  10. Once you've confirmed that it's working again, make you sure you reset its baud rate (typically 57k for APM) and VID number to match your other module.

(Thanks to Doug Barnett for these tips)

Comment by, Jan 12, 2012

I can't thank you enough for this guide, it has saved me a LOT of trouble!

Comment by, Mar 20, 2012

Inset picture is very confusing! It is the dominate illustration showing how to plug the XBee cable into the APM 2. It shows the ground pin ON THE LEFT. If you plug it in that way you burn out the XBee adapter.

Comment by, Apr 4, 2012

OK let's make it clear connecting xbee to usb and AMP2 to usb dont work. How about to power only from usb the AMP2? How can your clever way to detect usb can be passed and let it use only power from usb and xbee for comunication just for testing and escape for put all gear on amp 2 including lipo, esc? Many phone charger give 5v and over 500mA i have mine who give 2000mA and right usb for plug in to the AMP 2.

Comment by project member, Apr 4, 2012

stafford: I'm confused. The diagrams and photos all look right to me.

Comment by, May 25, 2012

Bogdan: I was able to get my Xbee working with the APM2 off of usb power. Not connected to the computer, but through a wall adapter. Just power the APM2 first WITHOUT plugging in the Xbee to it. After it's powered, then plug in the Xbee and it should trick the board into working with the Xbee.

Comment by, Aug 5, 2012

Ok, I've been trying all night to establish a link via XBEE series2, but with no luck. I'm powering the APM2 via USB through a wall adapter. and without changing to UART2. SO, what's wrong ?! and what's the default baudrate ?! i tried both 9.6 and 115.2 but with no luck !! I have to say that i tested both modules together and they read each other PERFECTLY. PLEASE, HELP !!!

Comment by project member, Aug 5, 2012

ahmedhassan: as the page above says in bold letters you can't use wireless telemetry while the USB is plugged in. They share the same same port.

Comment by, Aug 5, 2012

So USB through a wall adapter doesn't cunt ?! Ok, will power it with NO USB at all. THNX 4 the quick reply

Comment by, Aug 5, 2012

OK, I powered the APM2 via the output rail with JP1 mounted. The APM2 was up and LEDs flashing with the RX led solid and the TX led going nuts. baud rate was 57600 as stated, but still connecting to port times out !!! I noticed though that the TX and RX leds turn off three times, i think packets are received from the planner, but not interpreted ?! again, plz help !

Comment by project member, Aug 5, 2012

Have you already tested that the Xbees can communicate? (same VID, baud rates on the modules set to 57k, etc)?

Comment by, Aug 5, 2012

YES, they communicate perfectly. Again, I'm powering via output rail so that XBEE module uses UART0 with 57.6 baudrate. I just feel that the baudrate is the problem :? Do I have to use UART2 ???!

Comment by project member, Aug 5, 2012

Just to be clear: you have configured the Xbees in X-CTU so that each is running at 57k, and confirmed that they're talking to each other at that speed via the loopback?

Comment by, Aug 5, 2012

confirmed via writing in terminal on one XBEE's port and receiving at the terminal of the other XBEE's port, no losses at all. Never did the loopback !

Comment by project member, Aug 5, 2012

And they were set at 57k in X-CTU?

Comment by, Aug 5, 2012

I swear to GOD, YES :)

Comment by project member, Aug 5, 2012

What code is running on the APM2?

Comment by, Aug 5, 2012

the latest copter 2.7.1 and i just did the loopback test; 100% signal. it's really driving me crazy !!

Comment by project member, Aug 5, 2012

So, just to be clear: 1) You're able to connect via MAVLink over USB 2) You're using the 900Mhz Xbees recommended above (I haven't had luck with others), and set them up as described above. 3) You've got the right ground Xbee port selected in the MP and 57k baud. This will NOT be the same as the port Windows assigned to your USB 4) You've got the air Xbee plugged into the right pins on APM 2 as shown above. 5) You've disconnected the USB and powered the board via some other source (an ESC) 6) You've pressed connect again, but this time (over the wireless connection) it won't connect.

Yes on ALL counts?

Comment by, Aug 5, 2012

YES. But, the XBEE i'm using is this

Comment by project member, Aug 5, 2012

I'm afraid we don't support that one.

Comment by, Aug 5, 2012

But how does that make any difference ?! it's only a data link ?! i'm an embedded programmer, just point me where to write/ edit code

Comment by project member, Aug 5, 2012

Xbees are all different, and some come in mesh mode. You might check out this post for some of the other differences/ setup tips:

At any rate, I can't help further. I have no experience with the ones you're using.

Comment by, Aug 5, 2012

FYI, those are mine :D seriously; Xbee Pro 2.4 GHz 63mw modules !! WTH ?!

Comment by, Aug 12, 2012

FINALLY I found where the problem was: thanx to Vernon Barry @DYI forums. I used the UART0 port not the telemetry port and it worked. the MUX must have come without solder !!! I THINK THE TUTORIAL NEEDS TO WARN THE CLIENTS TO CHECK THEIR MUX CONNECTIONS !!

Comment by, Aug 22, 2012

Could you please provide more details what exactly need to be checked on this red rectangle?

Comment by, Aug 22, 2012

U will use this port instead of the default telemetry port.

Comment by, Aug 27, 2012

@ahmmedas: Oh! lovely...I was dying, and ur comments gave me life :P

Comment by, Oct 14, 2012

How will APM behave if Telemetry link is lost and I was flying with joystick? I plan to use just telemetry link without rc controls.


Comment by, Nov 18, 2012

I read about the failsafe function for that problem. If telemetry is loosing connection, the apm switches the mode to rtl.

Comment by, Dec 7, 2012

Hi to you all, I also have problems for the telemetrie to work with te apm2.0. using two xbee-pro (802.15.4)with xbee adapter, one on the pc via usb, and one on the apm via cable rx,tx,vin and grd. (teleport) Both working ok on the x-ctu via usb, communicating on 57k, no problem, but not on the apm2.0. Please need help. (I'm from Belgium, so my english is not perfect)

Comment by rajkiranjoshi, Jan 20, 2013

I am trying to connect Telemetry over Serial3. So as said (above) I have changed the Jumpers of 'AutoMUX' towards the side of UART2 (aka Serial3). I used the following simple code to test if both the connections (Serial and Serial3) are working: void setup() {

// initialize two serial ports: Serial.begin(115200); Serial3.begin(57600);

void loop() {

Serial.println("Port 0"); delay(500); Serial3.println("Port 3"); delay(500); }

I got perfect output on Serial (i.e. USB) connection and nothing on Serial3 (Telemetry). I tried connecting to both Telemetry port as well as UART2 on the right of red rectangle in the fig posted above. But no use. My connection just times out in both the cases.

Can anyone help me out of this?

Comment by, Feb 15, 2013

I made the serial test connection and the APM's USB port works well reading port0 , but when i switch to the Xbee com port and the default baud rate i got nothing in the serial monitor !!! , any advice ?

Comment by, Feb 19, 2013

my problem is the same as "rajkiran"

Comment by project member, Feb 19, 2013

As noted in the manual, you can't use telemetry while USB is plugged in.

Comment by, Mar 15, 2013

Hi to everyone,

Is any way to fix the telemetry port?

Comment by, Mar 29, 2013

Hi, I'm having the same issue as everyone above. I do not want to use the other serial ports as installing the pins to use the uart 0 or uart 2 port defeat the purpose of having a nice and clean telemetry port.

Comment by, Apr 1, 2013

yah i know that part saying "you can't use telemetry while USB is plugged in" , but could you explain this phrase to me " If you've got an Xbee attached to your APM, the USB cable will probably not provide enough power by itself to drive them both" cause i am seeing a contradiction here . ( because what i understood from 2nd phrase is that the xbee and usb are already connected to the APM and the only problem is that the usb may not provide enough power !!! )

Comment by project member, Apr 1, 2013

@karim See above: IMPORTANT: On APM 2, you cannot use the Xbee while your APM board is connected to the USB port. That's because the Xbee and USB share the same serial port, with some clever multiplexing to detect if the USB cable is plugged in and switching output to the USB if so.

Comment by project member, Apr 1, 2013

@Karim: Even though the XBee is not connected to the serial port, it still takes power from the USB port. You may need to disconnect if the power from the USB port is not enough.

Comment by, Apr 5, 2013


I have been looking around over boards for a while, seem like I'm using the wrong Baudrate, but I double checked that, so, I will state my problem here now anyways:

I have the APM 2.5 + Xbee Pro 802.15.4 modules (all set up accordingly to this tutorial).

Now, for the last part of this tutorial, I started with the APM 2.5 and plugged it in the computer via USB. It uses COM4, the correct BAUD rate and the Mission Planner software works perfectly. The console output in this program as well.

Now if I try it with the (ArduPilot?) Arduino IDE and use the serial monitor, I get a strange output (some ASCII chars) every second:

serial monitor output

Anybody a clue?

Comment by, Apr 11, 2013

@fufubeng if there is a strange ASCII output it's Ok ,just double check on Baud rate ,also before checking Baud check the correct serial port in Arduino IDE under tools .

Comment by, Apr 11, 2013

for people who have problems in telecom. port : here is what i did and works for me : 1- change the automux in the bottom to UART2 (the pads facing output side). 2-solder 4pin headers to the UART2+5v+GND , then use this port to connect the Xbee instead of the telecom. port as it have some issues !! (connect Tx2 in the APM with Din in the breakboard ,Rx2 with Dout). 3- use the demo code but with replacing any "Serial3" to "Serial2" 4- select the APM com port and baud 115... , then switch to the Xbee com port and baud 57...

Comment by, May 21, 2013

I'm having the same telemetry port issues. I have APM 2.5 with Xbee 2.4 802.15.4 firmware 10ED. The Xbees have been tested and communicate across multiple computers and from a computer to an Arduino Uno properly. MissionPlanner registers telemetry data when connected via USB, but that is obviously not wireless. It registers nothing and will not connect when trying to connect using the Xbee on the telemetry port.

Has anyone discovered a fix other than soldering extra connectors to the UART0 and/or UART2 ports on the board? I do not want to do that because the board would then not fit in the case which would make mounting more difficult.

Comment by project member, May 21, 2013

@km are you still powering your APM via the USB connection when you are testing your radios? If so, you need to power off another source.

Comment by, May 21, 2013

@cr: I was and then read that would be a possible issue. In my latest test I powered the APM 2.5 via 5V connector on the output rail with JP1 jumper connected and still had the issue. I have a power module on the way to test with, but my understanding is that power from the output rail should be sufficient to power the APM and the connected Xbee. Please let me know if this is incorrect.

Comment by project member, May 21, 2013

Power is not the issue. If you have the usb connected, telemetry is sent via usb not the radio. You have to disconnect the usb to redirect the telemetry to the radio

Comment by, May 28, 2013

Hi guys,

I want to know what "In-Flight" operations (commands/edits) that I can do on the Ardupilot code while flying?

For example waypoint & PID change by QGround and Mission planner. What else? Can I add to the code in-flight?

Sign in to add a comment
Powered by Google Project Hosting