← AI & Robotics Lab

How to Connect a Raspberry Pi 5 Companion Computer to Your Pixhawk Drone

Author: Daniel Jordan Viray

I wanted to share what I learned because a few of the steps tripped me up along the way

Feb 22, 2026 · Building the Drone · by Daniel Jordan Viray

So I just got my Raspberry Pi 5 successfully talking to my Pixhawk 2.4.8 running ArduPilot — and I wanted to share what I learned, because a few of the steps tripped me up along the way.

The Setup

I’m using a Raspberry Pi 5 as a companion computer connected to a Pixhawk 2.4.8 flight controller running ArduPilot. The goal is to run Python code on the Pi that controls the drone’s motors via the Pixhawk. The information flow looks like this:

Python script → Raspberry Pi → Pixhawk → Motors

I’m using DroneKit (a Python library) to send MAVLink commands from the Pi to the Pixhawk, which then handles the low-level motor control.

Software Setup

First things first — you’ll need to set up your Raspberry Pi with the right software stack. There’s plenty of documentation online for this, but at a high level you’ll need to install:

One thing that really had me spinning my wheels: the UART connection. The Raspberry Pi 5 uses its UART pins to communicate with the Pixhawk, but by default, Bluetooth occupies those serial pins. You need to disable Bluetooth on the Pi 5 so the UART pins are free to talk to the Pixhawk. Look up the documentation for your specific UART connection — this step is critical.

Troubleshooting the Connection

If you’re having trouble getting the Pi and Pixhawk to communicate over UART, here’s what I’d recommend: connect them via USB first. This lets you verify that the two devices can actually talk to each other before you introduce the complexity of the UART wiring.

You’ll also need to set the correct parameters on the Pixhawk using Mission Planner so the serial ports are configured to accept communication from the companion computer. Make sure the baud rates match on both ends.

Hardware Setup

Right now, my Raspberry Pi is powered externally via a USB-C power cord — but that’s just for bench testing. Eventually, everything needs to run off a single 3S 4200mAh LiPo battery. That one battery has to power the Pixhawk, the Raspberry Pi, the power distribution board, the ESCs, and the motors. Everything needs to fly as one self-contained unit.

Here’s how the power distribution works:

  1. XT60 cable comes out of the LiPo battery

  2. A power module feeds into the Pixhawk (this also provides voltage/current sensing)

  3. The power module continues on to a power distribution board that drives the ESCs and motors

  4. I added a splitter off the main power line — one leg continues to the power board/Pixhawk, and the other leg will power the Pi

  5. The Pi leg needs a step-down voltage converter (the LiPo outputs ~11.1V–12.6V, but the Pi needs 5V)

  6. The output of the step-down converter needs to terminate in a USB-C connector to plug into the Pi — which means I’ll be cutting and splicing some wires

What’s Next

Once the power situation is sorted, I’m planning to mount the Raspberry Pi to the bottom of the drone frame. That introduces a few concerns:

Auto-Boot Script

When the Pi is mounted on the drone, I won’t be SSH-ing into it before each flight. Instead, I’m planning to set up an auto-boot sequence — when the drone powers on, the Pi boots up, waits about 30 seconds for everything to initialize, and then automatically runs the Python flight script (arm motors, take off, hover, execute mission, etc.).

Indoor Flight Without GPS

Here’s where things get really interesting — and more complicated. I’m planning to remove the GPS module and fly indoors. Flying without a GPS lock is significantly more complex than outdoor GPS-guided flight. You can’t just use simple DroneKit takeoff commands without GPS. I’ll need to figure out alternative positioning methods or fly in a mode that doesn’t require a GPS lock.

Failsafes and Manual Override

I also need to figure out how to handle the Pixhawk’s failsafe modes — either disabling them or passing through them appropriately for autonomous indoor flight. I’ll still keep the RC controller connected as a manual override for safety, which is always a good idea when testing autonomous flight.

Wrapping Up

The main takeaway from this post: getting the Raspberry Pi 5 to communicate with the Pixhawk over UART is totally doable, but don’t skip disabling Bluetooth on the Pi, and verify your connection over USB first before troubleshooting UART issues. Once they’re talking, you can write Python scripts with DroneKit to control your drone programmatically — and that opens up a world of possibilities.

More posts coming as I work through the power distribution, mounting, and indoor autonomous flight challenges. Stay tuned.