Skip to content

Betaflight MAVLink Telemetry

jonpas edited this page Jan 31, 2019 · 9 revisions

This page describes how to wire a Betaflight flight controller board and a USB-to-TTL Serial Converter (USART) to get MAVLink Telemetry data out of Betaflight to your PC remotely, decode it and send it to DroneVis Server.

Note: Save files linked in this page with right-click and save as if they show up as text, as GitHub Wikis remove download attribute. Note: All instructions are for specific hardware we originally created this project with, own research is required to use other hardware!

Hardware:

  • Board: STM32F411 (STM32F411VE MCU)
  • Wi-Fi Module: ESP-01 (1MB) (ESP8266)
  • Adapter USB-to-TTL for UART: RS232 (CP2102)

Setup

Betaflight

Betaflight (STM32F411DISCOVERY target)

Betaflight Telemetry

  • Connect to Configurator via USER USB port
  • Go to "Configuration" (tab) -> "Other Features" (box) and enable "TELEMETRY"
  • "Save and Reboot"
  • Go to "Ports" (tab) and for "UART6" select "MAVLink" in "Telemetry Output" (dropdown) and set it to "115200"
  • "Save and Reboot"

Remote Connection

  • 2x ESP8266 required!

Betaflight to ESP8266 Module Connection

  • Flash mavesp8266 (instructions below under ESP8266 Flashing)
  • Connect the following pins (module pin-side, rest of board facing left -> board)
    • W b [GND__] [TX___] -> [GND] [PC7]
    • i a [GPIO2] [CH_PD] -> [___] [3V_]
    • F c [GPIO0] [RESET] -> [___] [___]
    • i k [RX___] [VCC__] -> [PC6] [3V_]
Test Connection
  • Download wifi_receive.py
  • Run $ python wifi_receive.py
  • Confirm data is received
    • Data is sent in MAVLink protocol (garbled without a decoder)

USB-to-TTL to ESP8266 Module Connection

  • Setup ESP8266 Bridge UDP-UART (instructions in same URL and below under ESP8266 Flashing)
  • Connect the following pins (module pin-side, rest of board facing left -> USB-to-TTL module)
    • W b [GND__] [TX___] -> [GND] [RX_]
    • i a [GPIO2] [CH_PD] -> [___] [3V_]
    • F c [GPIO0] [RESET] -> [___] [___]
    • i k [RX___] [VCC__] -> [TX_] [3V_]
  • Connect 3V on reliable power supply! Some USB-to-TTL modules do not provide enough current through them!
  • Connect USB-to-TTL to a USB port on PC
Test Connection
  • Download pymavlink (eg. via pip)
  • Download mavlink_listener.py
  • Run $ python mavlink_listener.py --device=<port> --baudrate=115200
    • Replace <port> with connected TTY/COM port (eg. Linux: /dev/ttyUSB0, Windows: COM0)
  • Confirm data is received
    • Data is sent in MAVLink protocol and will be shown decoded

Receiver

MAVLink Decoder (Python 3)

  • Run DroneVis Server (instructions here)
  • Download pymavlink (eg. via pip)
  • Run $ python givers/mavlink_giver.py -a <ip:port> -d <device>
    • Replace <ip:port> with IP and port of running DroneVis server (eg.: 127.0.0.1:8080)
    • Replace <device> with connected TTY/COM port (eg. Linux: /dev/ttyUSB0, Windows: COM0)

Other

ESP8266 Flashing

  • Download esptool
  • Connect the following pins (module pin-side, rest of board facing left -> USB-to-TTL module)
    • W b [GND__] [TX___] -> [GND] [PC7]
    • i a [GPIO2] [CH_PD] -> [___] [3V_]
    • F c [GPIO0] [RESET] -> [DTR] [RTS] (for Automatic Bootloader or only GPIO0 -> GND for Manual Bootloader)
    • i k [RX___] [VCC__] -> [PC6] [3V_]
  • Run $ esptool erase_flash
  • Run $ esptool write_flash 0x0 <flash_file.bin>