Guide to Real-Time Telemetry over 4G: Connecting a Raspberry Pi Zero W Companion Computer to a Drone
Real‑Time Telemetry over 4G: Connecting a Raspberry Pi Zero W Companion Computer to a Drone
Modern drone operators demand low‑latency, long‑range telemetry that works beyond the range of traditional 2.4 GHz radio links. Using a Raspberry Pi Zero W as a companion computer and a 4G LTE modem gives you exactly that – real‑time MAVLink telemetry streamed over the cellular network.
What You’ll Learn
- Hardware needed for a 4G telemetry bridge.
- Step‑by‑step software installation on Raspberry Pi Zero W.
- Configuring
mavproxy/mavlink-routerfor bidirectional MAVLink. - Testing connectivity and troubleshooting common issues.
1️⃣ Hardware Overview
The following components are required for a robust 4G telemetry setup.
| Component | Recommended Model | Why? |
|---|---|---|
| Companion Computer | Raspberry Pi Zero W | Compact, 802.11 n Wi‑Fi, GPIO access. |
| 4G LTE Modem | Huawei E8372h / Quectel EC25 Mini PCIe (via USB‑adapter) | USB‑OTG friendly, supports LTE‑Cat 4 + 5G fallback. |
| SIM Card | Data‑only plan (M2M) | Low‑latency, reliable packet data. |
| Power Supply | 5 V 2 A Li‑Po with UBEC | Ensures stable voltage under cellular bursts. |
| Connector | JST‑GH for Pi‑Zero UART, or TELEM‑2 for flight controller | Secure TX/RX wiring. |
All parts fit into a 3‑inch drone‑mounted case that you can 3‑D print. Keep the antenna clear of metal to avoid signal attenuation.
2️⃣ Install the Operating System
We recommend Raspberry Pi OS Lite (64‑bit) for its small footprint.
- Download the image and flash it with
balenaEtcher. - Create an empty
sshfile on the boot partition to enable SSH. - Insert the micro‑SD card, power the Pi, and connect via
ssh pi@raspberrypi.local(default passwordraspberry).
Once logged in, update packages:
sudo apt update && sudo apt full-upgrade -y
sudo reboot
3️⃣ Configure the 4G LTE Modem
Plug the USB modem into the Pi’s OTG port (use a powered USB hub if you need extra devices).
3.1 Install required tools
sudo apt install -y usb-modeswitch ppp usbutils minicom
3.2 Verify the modem is recognized
lsusb
# Example output: Bus 001 Device 005: ID 12d1:1f01 Huawei Technologies Co., Ltd. E8372h 4G LTE Modem
3.3 Create a qmi connection (recommended)
sudo apt install -y libqmi-utils
sudo qmicli -d /dev/cdc-wdm0 --connect-open
# Create a persistent systemd service
cat <<'EOF' | sudo tee /etc/systemd/system/qmi-4g.service
[Unit]
Description=QMI 4G LTE connection
After=network.target
[Service]
ExecStart=/usr/bin/qmicli -d /dev/cdc-wdm0 --connect --apn your_apn
Restart=on-failure
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl daemon-reload
sudo systemctl enable --now qmi-4g.service
Replace your_apn with the APN provided by your carrier.
3.4 Test the data link
ping -c 3 8.8.8.8
curl https://api.ipify.org
You should see a public IP address assigned by the LTE network.
4️⃣ Install and Configure MAVLink Routing
Two popular options exist: mavproxy (Python) and mavlink-router (C). This guide uses mavlink-router for lower CPU usage on the Pi Zero.
4.1 Install dependencies
sudo apt install -y git cmake build-essential libuv1-dev libjson-c-dev
git clone https://github.com/mavlink-router/mavlink-router.git
cd mavlink-router
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make -j$(nproc)
sudo make install
4️⃣2 Create a routing configuration
sudo tee /etc/mavlink-router.conf << 'EOF'
[General]
LogLevel=info
[UartEndpoint]
Device=/dev/serial0
Baud=921600
# Adjust if your flight controller uses a different baud rate
[UdpEndpoint]
Address=0.0.0.0
Port=14550
# Ground station will listen on this port (local Wi‑Fi)
[UdpEndpoint]
Address=your_4g_public_ip
Port=14560
# Remote ground station reachable over the internet
EOF
4️⃣3 Enable the service
sudo tee /etc/systemd/system/mavlink-router.service << 'EOF'
[Unit]
Description=MAVLink Router
After=network-online.target
Wants=network-online.target
[Service]
ExecStart=/usr/local/bin/mavlink-routerd -c /etc/mavlink-router.conf
Restart=on-failure
User=pi
Group=pi
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl daemon-reload
sudo systemctl enable --now mavlink-router.service
Now the Pi forwards MAVLink packets from the flight controller (UART) to both a local UDP port (for Wi‑Fi monitoring) and the remote 4G endpoint.
5️⃣ Ground‑Station Setup (Remote)
Your remote computer must listen on the public IP and port you defined (14560 in the example). A simple listener using mavlink-router or QGroundControl works.
5.1 Using QGroundControl (QGC)
- Open QGC → Settings → General → Comm Links.
- Add a new UDP link with
IP: your_4g_public_ipandPort: 14560. - Enable “Allow inbound traffic” on your router/firewall if you sit behind NAT.
5.2 Verify the stream
nc -ul 14560
# You should start seeing binary MAVLink traffic.
In QGC you’ll see the drone’s heartbeat, GPS, attitude, and live video (if you pipe the video feed separately).
6️⃣ End‑to‑End Test
Run the following checklist while the drone is on the ground (props removed).
- Check LTE signal strength:
sudo qmicli -d /dev/cdc-wdm0 --get-signal-strength. - Confirm
mavlink-routeris active:systemctl status mavlink-router. - On the ground station, verify heartbeat:
mavlink_console -i udp:0.0.0.0:14560or via QGC. - Send a command (e.g., arm) from the ground station and watch the telemetry LED on the flight controller.
If any step fails, consult the Callout Box below.
⚠️ Common Issues & Quick Fixes
- No LTE connection: Ensure the SIM is activated, APN is correct, and the modem is not in “Mass Storage” mode (run
usb_modeswitch). - High latency (>300 ms): Use a carrier with low‑latency M2M plan; avoid 3G fallback.
- UART communication drops: Verify
DeviceSpeedin/boot/config.txtmatches the flight controller’s baud rate and enable the UART overlay:dtoverlay=uart0,txd0_pin=14,rxd0_pin=15. - Port blocked by firewall: Open UDP 14560 in both the Pi’s iptables (
sudo iptables -A INPUT -p udp --dport 14560 -j ACCEPT) and any external router.
7️⃣ Performance Optimizations
The Pi Zero W has a 1 GHz ARM11 CPU and 512 MiB RAM. Keep the telemetry stack lightweight:
- Disable HDMI (
/boot/config.txt → hdmi_blanking=2) to free RAM. - Run
mavlink-routerin–no‑forward‑statsmode if not needed. - Use a static IP for the LTE interface to avoid DHCP delays on reconnection.
Conclusion
By following this guide, you transform a tiny Raspberry Pi Zero W into a powerful 4G telemetry bridge that streams real‑time MAVLink data over the cellular network. The setup is scalable, low‑cost, and compatible with any MAVLink‑based flight controller, giving you extended range, reliable command & control, and the foundation for future edge‑computing missions.
Ready to fly further? Explore adding RTK GNSS corrections over the same 4G link or integrate AI inference on the Pi for autonomous vision tasks.
Happy flying and stay connected!
Comments
Post a Comment