Archive for December, 2011

Routing APM communications to Internet

28/12/2011 4 comments

I’ve been wondering, what would be the easiest way to route telemetry and commands from APM to Internet. Using 3G modem, would provide almost unlimited range (I know there has been some discussions about this in DiyDrones forum. Here in Finland the GSM network is very covering, but due the way the cellular towers are optimized, maximum altitude where the connection works is probably less than 200 m.)

In theory, list of required hardware is not long. One just needs to receive messages from APM and encapsulate them to UDP packets and send via 3G modem and vice versa. Unfortunately handling PPP communications is too large task for simple microcontrollers. I ended up using BeagleBoard for the sake of easy development and since I had one at hand. I realize that BeagleBoard (which essentially is full computer by itself) is an overkill, but it’s not very heavy and fits easily inside Maja’s fuselage. Basically any embedded system, capable of running linux and acting as an usb host would do. Maybe in the future I figure out some additional tasks for BeagleBoard to do.




The software that handles the communications is a simple Python script. Since APM has no onboard configuration interface, the program fetches configuration at start-up (and every 5 minutes) from URL, given as parameter. Currently configuration consist on ground station IP-address and port. Since typically ground station is connected to internet with 3G modem, it’s IP-address is not fixed. Current address can be then updated to the configuration file and file uploaded to some known server.

When the script is running, it simply listens to serial port and when it receives valid MavLink packet, it sends to to ground station and vice versa. I made couple of fixes to UDP handling for APM Planner. By the time this text is published, modifications should already be included on the latest version (without the fixes, connection usually fails when Planner queries parameters from APM and expects to get those in a numbered order, but with UDP, packets may arrive in random order)




Testing setup

Hardware wise setup is very simple. Beagleboard needs to be powered from 5v source. Due to 3G modem, power demand is very “spiky”, so regulator must have enough power output (big enough capacitor helps too). I connected APM telemetry port to BeagleBoard main serial port. Since Beagle has standard RS-232 levels and APM uses +3.3v logic, I used common MAX3232 driver between those. The downside is that console on BeagleBoard’s only easily accessible serial port must then be disabled. Be sure to do this only after you make sure, you can connect to Beagle via internet.

It’s also possible to use second serial port on Beagle. It’s however not enable by default and enabling requires compiling new kernel. Second serial port uses +1.8v logic, so level shifter is needed.




  1. Script to connect using 3G modem
  2. Script to bring up interface at boot and reconnect if needed.
  3. Disable console on serial port
  4. Place configuration file on known server
  5. Script to launch MavProxy at boot



  1. Connect ground station to net and check it’s ip
  2. Update ip to configuration file and upload it to specified server
  3. Power-up the plane and wait until it BeagleBoard boots up (Usually 3G modems have some kind of indicator light notifying when it’s connected. You can use this to check when the plane is ready)
  4. From APM Planner, select “UDP” as port and press connect (Plane must be sending data at this point)
  5. Enjoy!