MPXAir docs GitHub
Hardware and integration

Connect your own ground station

How to make any ground station with a GPS and a serial link to the computer work with MPXAir.

Your ground station shares the USB/serial link with the aircraft telemetry (MAVLink). MPXAir picks your messages out of that stream, so you can send text lines between MAVLink packets, or MAVLink messages of your own. Choose whichever is easiest for your firmware, then pick the matching ground station type.

Rules for text lines

  • Each line starts with a fixed prefix (for example #GND or $GND,) and ends with \n.
  • Write the whole line at once, between MAVLink packets. Never insert it inside a MAVLink packet.
  • Use plain ASCII and keep lines under a few kilobytes.
  • MAVLink parsers skip text, so the aircraft link isn't disturbed.

Option 1 — JSON reply to a command

MPXAir sends a poll command (default #GND?, then \r\n) at the interval you choose. Your firmware answers with one line:

#GND {"lat":-35.363261,"lon":149.165230,"alt":584.2,"sats":11,"fix":3,"hdop":0.8}

Ground station type: Custom board — JSON replies. Set the field paths if yours differ (nested paths like gps.lat work). If you send degrees × 10⁷, set the position scale to 0.0000001.

// Arduino / ESP32 sketch (uses the TinyGPSPlus library)
#include <TinyGPSPlus.h>
TinyGPSPlus gps;
HardwareSerial GPSSerial(1);
String cmd;

void setup() {
  Serial.begin(115200);                       // USB link to the computer
  GPSSerial.begin(9600, SERIAL_8N1, 6, 7);    // GPS module: RX, TX pins
}

void loop() {
  while (GPSSerial.available()) gps.encode(GPSSerial.read());
  while (Serial.available()) {                // (forward everything else to your radio here)
    char c = Serial.read();
    if (c == '\n' || c == '\r') {
      if (cmd == "#GND?") {
        Serial.printf("#GND {\"lat\":%.7f,\"lon\":%.7f,\"alt\":%.1f,\"sats\":%u,\"fix\":%d,\"hdop\":%.1f}\n",
          gps.location.lat(), gps.location.lng(), gps.altitude.meters(),
          gps.satellites.value(), gps.location.isValid() ? 3 : 0, gps.hdop.hdop());
      }
      cmd = "";
    } else if (cmd.length() < 32) cmd += c;
  }
}

Option 2 — comma-separated lines

The simplest firmware: print one line a second, without being asked.

$GND,-35.363261,149.165230,584.2,11,3

Ground station type: Custom board — comma-separated replies. Columns: 1 latitude, 2 longitude, 3 altitude (m), 4 satellites, 5 fix. Change the column numbers if your order differs. Leave the poll command empty if the board sends lines by itself.

Option 3 — forward the GPS's NMEA

Pass the GPS module's $GPGGA / $GNGGA and $GPRMC / $GNRMC sentences straight into the USB stream (whole sentences, with their checksums). Ground station type: GPS mixed into the telemetry.

Send GPS_RAW_INT (24), GLOBAL_POSITION_INT (33) or GPS_INPUT (232) with a system ID other than the aircraft's. System 255 is the convention, and also works for ArduPilot's FOLLOW mode with FOLL_SYSID=255. Ground station type: MAVLink GPS from the ground station, with the matching system ID.

Tips

  • ESP32 boards can reset when DTR/RTS change. Keep Release DTR and RTS on for them.
  • Use Test now and open Raw message on the Ground tab while you develop.
  • MPXAir's built-in demo drone answers #GND? and #GCS status too, so you can compare against it.