# Long-distance Data-link using WiFi in Raw Mode
This page shows how to set up a companion computer with a camera (Logitech C920 or RaspberryPi camera) such that the video stream is transferred from the UAV to a ground computer and displayed in QGroundControl. It also provide a bidirectional telemetry link and TCP/IP tunnel for drone control during flight. If you manually control the drone with a Joystick from QGroundControl (which uses MAVLink) then you can use WFB-ng as single link for all drone communications (Video, MAVLink telemetry, remote control using a Joystick).
This setup uses WiFi in unconnected (broadcast) mode and software from the WFB-ng project (opens new window).
Before using WFB-ng check regulators allow this kind of WiFi use in your country.
# WFB-ng Overview
The WFB-ng project provides a data transport that use low-level WiFi packets to avoid the distance and latency limitations of the ordinary IEEE 802.11 stack.
The high level benefits of WFB-ng include:
- Low-latency video link.
- Bidirectional telemetry link (MAVLink).
- TCP/IP tunnel.
- Automatic TX diversity - use multiple cards on the ground to avoid antenna tracker.
- Full link encryption and authentication (using libsodium (opens new window)).
- Aggregation of MAVLink packets (pack small packets into batches before transmitting).
- Enhanced OSD (opens new window) for Raspberry PI or generic linux desktop with gstreamer.
Additional information is provided in the FAQ below.
# Hardware Setup
The hardware setup consists of the following parts:
On the UAV side:
Raspberry PI 3B/3B+/ZeroW
- WiFi module ALPHA AWUS036ACH (opens new window) or any other RTL8812au card.
On the ground side:
- Any computer with USB port and Linux (tested on ubuntu 18.04 x86-64)
- Raspberry PI connected via Ethernet to computer running QGroundControl on any OS.
# Hardware Modification
Alpha AWUS036ACH is a medium power card that uses a lot of current while transmitting. If you power it from ordinary USB2 it will reset the port on most ARM boards. If you connect it to USB3 port via native USB3 cable to a Linux laptop you can use it without modification.
For Raspberry PI (UAV or ground) it must be directly connected to 5V BEC (or high current power adapter in case of ground pi) in one of two ways:
- Make a custom USB cable (cut
+5Vwire from USB plug and connect it to BEC) (opens new window)
- Cut a
+5Vwire on PCB near USB port and wire it to BEC (don't do this if doubt - use custom cable instead).
You must also add a 470uF low ESR capacitor (like ESC has) between card +5v and ground to filter voltage spikes. You should integrate the capacitor with a custom USB cable. Without the capacitor you can get packet corruption or packet loss. Be aware of ground loop (opens new window) when using several ground wires.
But if you use special very high power cards from taobao/aliexpress then you MUST power it as described above in ANY case.
# UAV configuration
- Download Raspberry PI image from latest wfb-ng release (opens new window)
- Flash it to the UAV Raspberry PI
- Reboot it and ssh with standard credentials (pi/raspberry).
- Run actions for air role as displayed in motd.
- Setup camera pipeline. Open
/etc/systemd/system/fpv-camera.serviceand uncomment pipeline according to your camera (PI camera or Logitech camera)
/etc/wifibroadcast.cfgand configure WiFi channel according to your antenna setup (or use default #165 for 5.8GHz)
- Configure PX4 to output telemetry stream at speed 1500kbps (other UART speeds doesn't match well to RPI frequency dividers).
Connect Pixhawk uart to Raspberry PI uart. In
peer = 'serial:ttyS0:1500000'in
# Using a Linux Laptop as GCS (Harder than using a RasPi)
- On ground Linux development computer:
sudo apt install python3-all libpcap-dev libsodium-dev python3-pip python3-pyroute2 \ python3-future python3-twisted python3-serial iw virtualenv \ debhelper dh-python build-essential -y git clone -b stable https://github.com/svpcom/wfb-ng.git cd wfb-ng && make deb && sudo apt install ./deb_dist/wfb-ng*.deb
- Follow Setup HOWTO (opens new window) to complete installation
- Don't forget to copy
/etc/gs.keyfrom UAV side to ground side to bind two setups.
- Also don't forget to use the same frequency channel as on the UAV side.
# Using Raspberry PI as GCS (Easier)
If you have Windows, OSX, or don't want to setup WFB-ng to your Linux laptop then you can use the same prebuilt image and another Raspberry Pi:
- Flash image to the ground Raspberry Pi.
- Reboot it and SSH in with standard credentials (pi/raspberry).
- Run actions for ground role as displayed in motd, but skip setup of
- Connect your laptop and ground RasPi via ethernet and configure IP addresses
/etc/wifibroadcast.cfgand set the IP address of the laptop in
# QGroundControl Setup
- Run QGroundControl and set
RTP h264on port 5600 as video source
- Use default settings (udp on port 14550) as mavlink source
# Tuning Radio Settings
With default settings WFB use radio channel 165 (5825 MHz), width 20MHz, MCS #1 (QPSK 1/2) with long GI. This provides ~7 mbit/s of effective speed (i.e. usable speed after FEC and packet encoding) for both directions in sum, because WiFi is half-duplex. So it is suitable for video down stream 720p@49fps (4 mbit/s) + two full-speed telemetry streams (uplink and downlink). If you need a higher bandwidth you can use other MCS index (for example 2 or greater)
# Antennas and Diversity
For simple cases you can use omnidirectional antennas with linear (that bundled with wifi cards) or circular leaf (circularly polarized Coverleaf Antenna (opens new window)) polarization.
If you want to setup long distance link you can use multiple wifi adapters with directional and omnidirectional antennas. TX/RX diversity for multiple adapters supported out of box (just add multiple NICs to
If your WiFi adapter has two antennas (like Alfa AWU036ACH) TX diversity is implemented via STBC (opens new window).
Cards with 4 ports (like Alfa AWUS1900) are currently not supported.
Q: What type of data can be transmitted using wfb-ng?
A: Any UDP with packet size <= 1445. For example x264 inside RTP or MAVLink.
Q: What are transmission guarantees?
A: Wifibroadcast uses FEC (forward error correction). You can tune it (both TX and RX simultaneously!) to fit your needs.
Q How far I can fly and still connect?
A It depends on your antennas and WiFi cards. With Alfa AWU036ACH and 20dBi patch antenna on the ground ~20km is possible.
Don't use band that the RC TX operates on! Or setup RTL properly to avoid model loss.
Q: Is only Raspberry PI supported?
A: WFB-ng is not tied to any GPU - it operates with UDP packets. But to get RTP stream you need a video encoder (which encodes raw data from camera to x264 stream), or you must use a camera with a hardware video codec like Logitech C920 or Ethernet security cameras.
# What ARM Boards are Recommended for the UAV?
- RPI3b/3b+/ZeroW. Prebuilt images are available, but it supports only h264 video for CSI cameras.
- Jetson Nano. It supports h264 and h265 but you need to setup it yourself according to Setup HOWTO (opens new window)
You can use any other Linux ARM board, but you need to use an Ethernet or USB camera with built-in hardware video codecs (such as Logitech C920).
WFB-ng puts the WiFi cards into monitor mode. This mode allows to send and receive arbitrary packets without association and waiting for ACK packets.