Use Raspberry pi to control Pixhawk4



I would like to execute Dronecode SDK examples on Pixhawk4.
I saw there are some suggestions to execute examples like this: ./takeoff_land udp://:14540, ./takeoff_land serial://path/

I connected Pixhawk4 and Raspberry Pi by TELEM2 and USB2TTL pins.
What should i do give the URL parameter?
I even don’t know they were actually connected. There is nothing new device when i type a lsusb command on raspberry pi.

Please give me a hint.

1 Like

Hm, so lsusb is a good start. The USB2TTL device should definitely show up. Make sure that the Raspberry Pi has enough power to power the USB devices.

Also, you can try using screen to check if anything is arriving over serial:

screen /dev/ttyUSB0 57600

There is some more info here:

And supposedly with the param SYS_COMPANION you can set the baudrate according to:

Once the USB device shows up, the permissions are correct and you see mavlink bytes arriving in screen, you can try the Dronecode SDK again.

The path should be something like:

./takeoff_land serial:///dev/ttyUSB0:57600

@DaeunGod, to identify the tty port name/number, you can also use the linux command “dmesg -wHT”. Press enter, then connect the USB2TTL device… the next message on screen should tell you the name of the port :wink:


@JulianOes @elBarto Thank you for helping me.

I found the tty port name and number. It is /dev/ttyUSB0.

but, Still they doesn’t look connected. i try to check anything arriving by using screen /dev/ttyUSB0 57600.
It doesn’t show anything. I think i had some mistake when set Pixhawk’s parameters.
That is i can’t find these parameters on QGroundControl.

Please help.

ps) This is what i execute the example.

./takeoff_and_land serial:///dev/ttyUSB0:57600

[07:30:04|Info ] DronecodeSDK version: 0.6.1 (dronecode_sdk_impl.cpp:25)
[07:30:04|Error] Error: no system found. (dronecode_sdk_impl.cpp:223)
Waiting to discover system…
Discovered system with UUID: 0
Discovered a component with type 0
[07:30:06|Warn ] sending again, retries to do: 3 (511). (mavlink_commands.cpp:248)
[07:30:07|Warn ] sending again, retries to do: 2 (511). (mavlink_commands.cpp:248)
[07:30:07|Warn ] sending again, retries to do: 1 (511). (mavlink_commands.cpp:248)
[07:30:08|Error] Retrying failed (511) (mavlink_commands.cpp:266)
Setting rate failed:Timeout


So, when you search in the param tab for MAV_ or SER_ what parameters do you see?

1 Like

check if you can find these one:


If you find them instead of the other ones, it means that you have the ArduPilot firmware running and not the PX4.
You can also check if the ArduPilot label is present near the top right corner of the QGroundControl (see picture here:

1 Like

Here they are.

And this is what i found after connected each other.
@elBarto There is a px4 pro label on the top right corner of the QGroundControl. So i think i’m using PX4.

1 Like

You’re right, they changed the name. Look for SYS_COMPANION and change its value to “Companion Link (921600 baud, 8N1)”, then set the baudrate accordingly (e.g. “screen /dev/ttyUSB0 921600”). It should work!

1 Like


I really appreciate your help.
I found the parameter you said and changed the baudrate. But it does not work yet.
There’s one thing unusual. The Tx LED blinks when the USB2TTL module is plugged into the laptop, but it does not blink when plugged into the Raspberry pi.(Rx LED does not blink both. Also there is no message on screen command) Maybe USB2TTL module has a problem?

The power of the raspberry pi is connected by the adapter, and the Pixhawk is powered by the battery.

Thanks again.


I am sorry to hear that.
Does it work on your laptop? I mean, if you connect the USB2TTL device to your laptop, can you get any message? You can use screen as well if you have any Linux distribution or Putty if you have Windows installed.

1 Like

No, It does not. Only Tx LED blinks and no message from Pixhawk. The laptop uses Linux 14.04.

I tried to connect from raspberry pi on Linux mate and Raspbian. but still it doesn’t connected.
I used MAVProxy to Check connection. but it said nothing neither. I think Pixhawk doesn’t send a message via TELEM2 or I should give a permission to send or receive messages.

I checked USB2TTL and TELEM2’s male port(6 pin cable) connection using digital multimeter. it was well connected. So I really don’t have idea why they aren’t connected.


Actually I am running short of ideas, but… you can still try this:

  1. connect the USB2TTL device to TELEM1 (you have to disconnect the telemetry radio);
  2. set the baudrate to 57600 on the RaspberryPi/Laptop side (screen /dev/ttyUSB0 57600)
  3. launch QGroundControl and see if it can connect to the Pixhawk using the cable instead of the radio.

This way you can check that the USB2TTL device is working properly and the cable is fine. Are you sure that the cable pinout is correct? Maybe TX and RX are swapped

1 Like


Thank you so much. I couldn’t have done this without you.

I’m really stupid. Yes, TX and RX are swapped also I should change the baudrate 57600. Then I can get some kind of messages from Pixhawk4.
But still, Raspberry Pi does not find the Pixhawk.
When I type a command as ./takeoff_land serial:///dev/ttyUSB0:57600. Then It said No system found, exiting.

I tried this on offboard mode, manual mode, stabilize mode.

This is the result of connecting USB to 5pin and running the example.

I think it will work if I fix a little bit.

1 Like

It won’t help to try different examples if it can’t find the the Pixhawk anyway.

So you’re saying it doesn’t work on the Raspberry Pi but your screenshot is of the hos kimchi-desktop, so your Raspberry Pi is named kimchi-desktop?