Ardupilot / PX4

This page contains setup and usage details for using the cellular M.2 PCB with Ardupilot and PX4 based systems - specifically using the CBUnmanned UAV Router and Tailscale.

These instructions are probably not the quickest/easiest way to get this all configured and working, but it at least works for me.

It is assumed that Initial testing with PC and Mounting has already been followed.

This guide uses a serial connection between the router and flight controller, but ethernet should also work.

Warning! Most serial/telemetry connectors and 5V outputs on standard Ardupilot/PX4 flight controllers cannot supply enough current for higher power devices like cellular modules. Use a dedicated 5V regulator or BEC.

Parts needed:

  • PC

  • JC M.2 cellular adapter PCB

  • Compatible cellular module (EM7455)

  • Antennas - NGFF / MHF4 / IPEX if using EM7455, for 3G/4G frequencies

  • SIM card (3G/4G)

  • CBU UAV Router

  • Cube Orange+ (or other Ardupilot / PX4 flight controller)

  • USB to Ethernet adapter (if you are using a PC without an ethernet port)

  • 5V regulator/BEC (do not power directly from standard FC 5V)

  • 4-pin JST-GH to 4-pin JST-GH cable for USB connection

  • 4-pin JST cable to 5V regulator for power

  • 4-pin JST-GH cable for serial connection with FC (to 6-pin JST-GH for pixhawk style FCs like Cube Orange)

  • M3 bolts for M.2 cellular module, M.2 adapter PCB, and UAV Router

    • M3 spacers if stacking

    • Low-profile or button head for under M.2 cellular module.

Physical Connection

  • Connect M.2 adapter PCB and CBU UAV Router using 4-pin JST-GH cable. Ideally avoid running alongside noisy signals (ESCs etc.).

  • Power CBU UAV Router using dedicated 5V regulator.

  • Connect CBU UAV Router to FC using serial connection.

  • Set up cellular module as per Initial testing with PC

  • Connect CBU UAV router LAN to PC ethernet (or ethernet to USB adapter)

Tailscale Account Setup

Tailscale is used to create a secure point-to-point connection between the UAV Router and another device (i.e. ground station PC).

If you do not already have a Tailscale account, go to https://tailscale.com/ and create an account (or login with a Google account).

Add two devices (PCs you intend to connect to the UAV is a good place to start) and test the connection as shown on the setup page.

Go to the Admin Console, which will show all 'machines' that you have access to with your Tailscale account. From here you can also share devices with other accounts, and see devices shared with your account.

Flight Control Setup

Configure the serial / telemetry port on your flight controller with MAVLink2 protocol, and a baud rate of 115200.

CBU UAV Router / OpenWRT Setup

Firmware Prep

See https://wiki.cbunmanned.com/wiki/products/openwrt-uav-router for more comprehensive, up to date information.

  1. Go to https://firmware-selector.openwrt.org/, search for HILINK HLK-7628N. At the time of writing there are config issues with 24.x firmware, so select the latest 23.x from the dropdown.

  2. Open the customize installed packages dropdown and add the following to the installed packages box: kmod-usb-core kmod-usb2 tailscale ser2net nano iptables-nft kmod-ipt-conntrack kmod-ipt-conntrack-extra kmod-ipt-conntrack-label kmod-nft-nat kmod-ipt-nat kmod-usb-net-cdc-mbim umbim luci-proto-mbim kmod-usb-serial-option picocom

  3. and the following to the script to run box:

uci set wireless.radio0.cell_density='0'
uci set wireless.default_radio0.ssid='CBU-Router'
uci set wireless.default_radio0.encryption='psk2'
uci set wireless.default_radio0.key='CBUnmanned'
uci set wireless.@wifi-device[0].disabled=0 
  1. Click request build

  2. When build is successful, click SYSUPGRADE button to download the new image .bin file.

  3. Connect 5V power to CBU UAV Router.

Connect and Update Firmware

  1. Once powered, connect to a PC using the ethernet adapter (use a ethernet-USB adapter if needed)

  2. Once connected, open a web browser and go to 192.168.1.1

  3. User login: root, there is no password by default (no need to set one, we are about to flash new firmware)

  4. Flash generated firmware

    1. Go to system > backup / flash firmware > flash new firmware image

    2. Select and upload previously generated firmware

    3. Untick 'keep settings'

    4. Press continue

    5. Wait a few minutes

Connect to WiFi

  1. Unplug ethernet adapter and plug back in

  2. Wait a few minutes

  3. Go to 192.168.1.1

  4. Log back in and set a password

  5. follow the Web interface instructions to connect to a WiFi network

    1. edit the LAN interface to 192.168.2.1

    2. click save

    3. click save & apply

    4. Appy with revert after connectivity loss

    5. quickly go to 192.168.2.1 (you should see the web interface and be able to log in)

    6. go to network > wireless

    7. click scan

    8. select relevant wifi network (if also using cellular module later, choosing hotspot makes testing this easier as it can be turned off)

    9. tick replace wireless configuration

    10. enter password

    11. submit

    12. click save

    13. click save & apply

    14. wait for configuration changes to load

Serial Telemetry Setup

  1. Install PuTTY (or other SSH tool)

  2. connect to 192.168.2.1

  3. accept any security alert

  4. login as 'root' with previously chosen password

  5. Connect serial port of UAV Router (R1/T1) to serial port on flight controller (that has been configured to MAVLink2)

  6. Try to connect to the FC in Mission Planner using TCP option with IP 1982.168.2.1 and remote port 5760 (using the same laptop connected via Ethernet or Wi-Fi)

Tailscale Setup

These steps roughly follow https://openwrt.org/docs/guide-user/services/vpn/tailscale/start

  1. Use PuTTY (or similar) to SSH back into the router at 192.168.2.1

  2. try to start tailscale with tailscale up

  3. if you get an error saying 'failed to connect to local tailscaled'

    1. run opkg install iptables-nft kmod-ipt-conntrack kmod-ipt-conntrack-extra kmod-ipt-conntrack-label kmod-nft-nat kmod-ipt-nat

    2. then service tailscale restart

    3. then try tailscale up again

  4. It should give you a tailscale URL - copy this into your web browser and login

  5. click connect

  6. you should see 'success' in the router SSH terminal, and it should show up as connected (with a green dot) in the Tailscale machines list

  7. Rename machine if desired

  8. log back into the 192.168.2.1 OpenWrt web interface

  9. go to network > interfaces > add new interface

    1. name: tailscale, protocol: Unmanaged, device: tailscale0

    2. click Create interface

    3. click save.

  10. go to network > firewall

    1. add a new zone

    2. name: tailscale

    3. input: accept

    4. output: accept

    5. forward: accept

    6. masquerading: tick

    7. MSS clamping: tick

    8. covered networks: tailscale

    9. allow forward to destination zones: LAN

    10. allow forward to destination zones: LAN

    11. click save

    12. click save & apply

    13. wait for config to apply

    14. run service tailscale restart in SSH terminal, or reboot router.

  11. Copy the 100.xxx.yyy.zzz IP address and try to connect to the FC in Mission Planner, again with TCP and port as 5760.

  12. If successful, try using a different PC which is connected to the same Tailscale network, but not on the same physical / WiFi network.

JC M.2 to USB Cellular Setup

Steps loosly based on https://openwrt.org/docs/guide-user/network/wan/wwan/ltedongle

  1. Connect M.2 cellular module (already tested as per Initial testing with PC) to UAV router's USB connector

  2. SSH into router using PuTTY (or similar) using either local IP 192.168.2.1, or tailscale IP.

  3. run ls -l /dev/cdc* to check if the cellular module is found (you should see something like /dev/cdc-wdm0

    1. if not, first run opkg update

    2. then opkg install kmod-usb-net-cdc-mbim umbim luci-proto-mbim kmod-usb-serial-option picocom

    3. reboot router

    4. wait a few minutes

    5. reconnect via SSH

    6. try again

  4. log back into OpenWrt web interface

  5. go to network > interfaces

    1. add new interface

    2. name: cellular

    3. protocol MBIM Cellular (reboot first if not available)

    4. create interface

    5. modem device: /dev/cdc-wdm0

    6. input relevant APN. This will depend on the network SIM card you have installed. It will likely be in a format such as mob.asm.net (SMARTY), mobile.o2.co.uk (o2)

    7. PDP Type: IPv4 only (usually)

    8. go to firewall settings

    9. choose WAN

    10. click save

    11. click save & apply

  6. turn off hotspot or go out of wifi range (to force cellular connection)

  7. try to connect to the FC in Mission Planner, using TCP with the tailscale IP for the router and port as 5760.

Camera Setup

Ethernet / IP cameras can also be connected to the router for relatively low-latency video over cellular. The below guidance is based on the SIYI A8 Mini, and assumes the same working setup as above.

  1. Connect camera ethernet port to UAV Router (custom JST-GH cable)

  2. Connect camera to power source (11V-25.2V or 3S to 6S)

  3. Change camera IP

    1. In 'gimbal config' change:

      1. IP Config to a suitable IP on the same subnet as the router, e.g. 192.168.2.100

      2. Gateway IP to 192.168.2.1

      3. Coding format to H264

      4. Video Output Mode to Close

    2. Click Save

  4. Set Tailscale to advertise LAN

    1. connect to router via SSH

    2. run tailscale up --advertise-routes=192.168.2.0/24 (or tailscale up --advertise-routes=192.168.2.0/24 -ssh if you had Tailscale SSH to machine enabled)

    3. go to the Tailscale admin console and select the UAV router machine

    4. approve the subnet

  5. Change Tailscale firewall rule on UAV router

    1. login to the openwrt web interface

    2. go to network > firewall > traffic rules

    3. add a new rule:

      1. Name Allow Tailscale to LAN

      2. Source Zone tailscale

      3. Destination Zone lan

      4. Action Accept

    4. Click save

    5. Click save and apply

  6. Connect to video output https://ardupilot.org/planner/docs/live-video.html#live-video

    1. start Mission Planner

    2. right click on the HUD and select Video > Set GStreamer Source

    3. input the GStreamer pipeline: rtspsrc location=rtsp://192.168.2.100:8554/main.264 latency=0 ! queue ! application/x-rtp ! rtph264depay ! avdec_h264 ! videoconvert ! video/x-raw,format=BGRA ! appsink name=outsink

  7. You should now see video!

Last updated