Pixhawk 6C to RPi 4 connection

Hi all !

I have seen posts about connecting a Pixhawk to a RPi, but none of the solutions found seem to work for me.

I have set up everything as described here: Communicating with Raspberry Pi via MAVLink — Dev documentation. In addition to that, I changed the config.txt file to add “dtoverlay=disable-bt”

Here are a few things I tried:

  • changing the baud rate from 921600 to 57600 or 115200 (on both the pixhawk and the command on the RPi).
  • uploading a different image on the RPi (the default it had was NOOBS). I chose the Rpanion image as described here New Companion Computer software: Rpanion-server, as it seemed to have solves some issues previously.
  • changed the connection cable between the Pixhawk and the RPi. I am now working with a cable bought from an electronic store (Dupont to JST-GH 6 pin). I only connect TX, RX and GND.
  • Powering the Pixhawk through the power module and battery rather than through USB.

I am new to rovers, and any insight would be greatly appreciated!

I ended up trying the USB connection, and this is working. So I was wondering, worst comes to worst, would I loose anything by using USB instead of serial?

Thanks all!

1 Like

If you’re using the Rpanion-server image, and can’t get a connection:

  • Check the serial protocol for the port is set to MAVLink2
  • Try reversing the rx/tx wires

Hi! Thanks a lot for the reply :slight_smile: However, I tried what you said and it did not work. Here is the config I currently have for serial port Telem2 on which I plug the Pixhawk.


I re-uploaded the rpanion image on my SD card today and started from scratch again. Now, I get the “Waiting for heartbeat” message and it just stays that way for port ttyAMA0. For port serial0, I get a “link1 down” error message in addition.
I am wondering if there is something obvious I ve been missing (do I need to connect the GPS/switch to the Pixhawk for some reason?).
Finally, I don’t have the GUI interface for the Rpanion server, I don’t know what that’s due to… (or if something needs to be done to display it).
Thanks a lot for your help!! :smiley:

The web GUI is at http://[Rpi IP address]:3000

You need to enable MAVLink streaming using the Web GUI. It’s not enabled by default.

1 Like

Hmm… I don’t think I understand what you mean by enabling MAVLink streaming, I didn’t read about that before. Any chance you could be a little more specific ? This is my first Pixhawk I am just starting !

I actually got the GUI interface running now. I input the same parameters as I programmed into the pixhawk (baudrate and mavlink version), and yet there is nothing going on still…

I checked that the TX and RX pins were working by doing a loop and I got the signal I sent back. I would like to check if the Telem2 port on the Pixhawk is working ok next.

Any help is greatly appreciated :smiley:

That is very odd. Can you post of photo of the exact setup you’re using for the telemetry?

Yes, definitely check that.

You wouldn’t be the first who got caught out with two different power-sources causing a mismatch of power level to ground.
Options:
a) Try using USB cable between the two and see what happens. This should ensure both units work on same power level (Ground & Positive)
…just seen you’ve tried the USB cable and it worked.
b) If you go USB from Pi to Telem Port use the + wire as well. But make sure on your FC it actually supports 5V and not just 3V.
c) Below is a drawing on how I connected my Pi to Pixhawk6x. - Worked for me after making some slight changes to serial setup in Buster.

My consideration when using a USB cable was that it potentially takes away a power source for the FC. In other words you’d loose one redundancy in regards to power supply.

  • Main power usually from PM
  • Secondary can be applied via USB port (I use a 5V voltage reducer/regulator connected to battery) In that way if power fails from PM the FC still has power via the USB port.


That’s my setup on Telem2 port. On the image, they are not powered on, but I just add the power cable on the RPi, and plug the Pixhawk to the Power Module (PM07) that’s plugged into a battery.
The USB ports on the RPi are used for a keyboard and mouse. It’s also wired to the Internet and to a screen through HDMI.
Let me know if something isn’t fully clear! And thanks for your help !!

Hi!
That diagram got me confused for a while because the numbering of the pins on the Pixhawk 6x’s ports are reversed (pin 1 left and increases as you go right) compared with the Pixhawk 6c (pin 1 to the right and increases as you go left).
As you see on my previous message, I did not connect the power pin, but apart from that and the numbering inversion mentioned above, I feel like it looks similar.

Yes, that’s true, you loose a potential power backup. I wasn’t planning on using that, but for some reason I still feel like connecting in serial would have been best. If it indeed does the same job though, I might have to go with USB…

I never tried going from USB pi to Telem port, that would take a bit of cable mingling that’s not part of my job description :innocent:

Thanks for your help!

Little update: Today I tried connecting to the TELEM3 port instead of TELEM2.
I get an output but it’s very strange. I don’t get anything on the GUI interface. Maybe because my port is ttyS0 and not serial0?


If I change my baudrate to the “default values” seen in the GUI interface (baud = 9600 and Mavlink 1 instead of 2), I don’t get all the weird characters, but the connection keeps breaking and coming back on again… (see below). Any insight on that?

Yep, that all looks correct.

Interesting. The screenshot definitely shows a connection, but there’s a fair bit of corruption (noise) - shown by the weird characters every now and again.

I’d suggest trying a lower baudrate to reduce the effect of the noise.

ttyS0 and serial0 are the same port on recent (<2 years) releases of RasPiOS.

Can you provide:

  1. the output of “raspi-gpio get”,
  2. the contents of /boot/config.txt, and
  3. the contents of /boot/cmdline.txt

You’ve missed the point with my diagram.
→ You need to connect the power wire (positive) as well when connecting from two power sources !

( One power source powering both units = 2 signal wires + ground = OK
Different power source for each unit = 2 signal wires + ground + positive=OK
Different power source for each unit = 2 signal wires + ground = BAD as signal potential mismatch due to missing positive wire!)

I see, but how come I would get a different response for them then? In the image below, you can see that the same command for port ttyS0 and port serial0 gives very different outputs… Note that this capture has been taken while the Pixhawk was disconnected.


Today, I keep getting the “could not configure port” error for port ttyS0. Also, when I plug the pixhawk on port TELEM3, it has the most odd behavior, it reboots, I loose my ssh connection, and it sometimes starts printing 10,000 lines of text (if I plug an HDMI cable directly onto the Pi).
I litterally have no idea what’s going on, and I would be really interested to have your opinion!

As mentioned before, I am having trouble connecting the Pixhawk, so I printed out what you asked for WITHOUT the Pixhawk plugged into the Pi. I hope it still is helpful!


OK, I do get your point now, I’ll try with the positive cable plugged in. According to holybro documentation Pixhawk 6C Ports - Holybro Docs I should be fine with a +5V pin for both Telem2 & 3.

Some new information: every once in a while, connection “works” again (I am getting something…). I set the baudrate for TELEM3 port to 9600 (9 in mission planner).

Here is what I get now. The connection seems very unstable? It is also VERY slow.


Connection is slow because at that baudrate there is to much data to be sent and not enough time. You need to set it to 57600 for regular telemetry data flow and even higher (if possible) when dealing with extra data, like GPS, LIDAR, Air-speed sensor,…
(With the slower baudrate setting it is like trying to pour a bucket full of water down a garden hose - needless to say it is very slow and you will spill a lot of water whilst trying to get it into that hose. In case of a signal connection this “spillage” causes a data overflow which is likely to restart your connection repeatedly.- Hence you dropouts)

Yes, correct. The end pin is rated at +5V. Just do not by accident connect the positive wire to any signal wires (TX or RX) as those are only rated at 3.3V. (Same on my Pixhawk 6x)

Looking at your screenshot of /boot/cmdline.txt, the RPi login console is enabled on serial, leaving it unusable for a telemetry connection.

See https://www.raspberrypi.com/documentation/computers/configuration.html#disabling-the-linux-serial-console for instructions on how to disable.

You are right, I don’t know why I had it enabled. It didn’t change a whole lot. However, I was doing some tests this afternoon on my RX and TX ports (trying to send an echo into my serial port).
The only configuration that appears to be working is when I don’t disable the bluetooth in the config.txt file and change the pin usage of uart0 (dtoverlay=uart0, txd0_pin=32, rxd0_pin=33, pin_func=7).
I am not entirely sure what that means, it has been so hard to find clear explanations online… But when I plug my autopilot on TELEM3 and run mavproxy.py --master=/dev/serial1, I now get a “good” output (see below for example - the commands I typed are bolded).

mavproxy.py --master=/dev/serial1
Connect /dev/serial1 source_system=255
Log Directory:
Telemetry log: mav.tlog
Waiting for heartbeat from /dev/serial1
MAV> Detected vehicle 1:1 on link 0
online system 1
MANUAL> Mode MANUAL
fence present
AP: ArduRover V4.2.3 (2172cfb3)
AP: ChibiOS: 38022f4f
AP: Pixhawk6C 003C002E 30315110 34373938
AP: RCOut: PWM:1-16
AP: IMU0: fast sampling enabled 2.0kHz
AP: ArduRover V4.2.3 (2172cfb3)
AP: ChibiOS: 38022f4f
AP: Pixhawk6C 003C002E 30315110 34373938
AP: RCOut: PWM:1-16
AP: IMU0: fast sampling enabled 2.0kHz
AP: ArduRover V4.2.3 (2172cfb3)
AP: ChibiOS: 38022f4f
AP: Pixhawk6C 003C002E 30315110 34373938
AP: RCOut: PWM:1-16
AP: IMU0: fast sampling enabled 2.0kHz
wp list
MANUAL> Requesting 2 waypoints t=Fri Aug 18 21:25:03 2023 now=Fri Aug 18 21:25:03 2023
re-requesting WPs []
16 0 0.0000000000 0.0000000000 0.000000 p1=0.0 p2=0.0 p3=0.0 p4=0.0 cur=0 auto=1
16 3 46.8059848000 -71.2453723000 100.000000 p1=0.0 p2=0.0 p3=0.0 p4=0.0 cur=0 auto=1
Saved 2 waypoints to way.txt
Saved waypoints to way.txt
time #no time because I don’t have GPS signal as I am testing indoors
MANUAL> No SYSTEM_TIME time available
status
MANUAL> Counters: MasterIn:[1800] MasterOut:85 FGearIn:0 FGearOut:0 Slave:0
MAV Errors: 0
None
55: AHRS {omegaIx : 0.0019977926276624203, omegaIy : -0.0016852348344400525, omegaIz : 0.00018157126032747328, accel_weight : 0.0, renorm_val : 0.0, error_rp : 0.00041464477544650435, error_yaw : 1.0}
55: AHRS2 {roll : -0.19092777371406555, pitch : 0.2435748130083084, yaw : 0.20045746862888336, altitude : 0.0, lat : 0, lng : 0}
54: ATTITUDE {time_boot_ms : 417459, roll : -0.19188277423381805, pitch : 0.2448255866765976, yaw : 0.5812029838562012, rollspeed : -0.001122887246310711, pitchspeed : -0.0005308238323777914, yawspeed : 0.0006290107266977429}
55: BATTERY_STATUS {id : 0, battery_function : 0, type : 0, temperature : 32767, voltages : [18738, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535], current_battery : 2, current_consumed : 3, energy_consumed : 2, battery_remaining : 99, time_remaining : 0, charge_state : 1, voltages_ext : [0, 0, 0, 0], mode : 0, fault_bitmask : 0}
55: BATTERY_STATUS {id : 0, battery_function : 0, type : 0, temperature : 32767, voltages : [18738, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535], current_battery : 2, current_consumed : 3, energy_consumed : 2, battery_remaining : 99, time_remaining : 0, charge_state : 1, voltages_ext : [0, 0, 0, 0], mode : 0, fault_bitmask : 0}
42: COMMAND_ACK {command : 410, result : 4, progress : 0, result_param2 : 0, target_system : 255, target_component : 230}
55: EKF_STATUS_REPORT {flags : 0, velocity_variance : 0.0, pos_horiz_variance : 0.0015112903201952577, pos_vert_variance : 0.0027783529367297888, compass_variance : 0.0, terrain_alt_variance : 0.0, airspeed_variance : 0.0}
374: FILE_TRANSFER_PROTOCOL {target_network : 0, target_system : 255, target_component : 230, payload : [77, 0, 3, 128, 80, 15, 0, 0, 240, 20, 0, 0, 69, 76, 88, 89, 0, 1, 57, 80, 79, 83, 90, 1, 1, 57, 86, 69, 76, 90, 0, 1, 41, 89, 65, 87, 0, 2, 119, 95, 79, 80, 84, 73, 79, 78, 83, 1, 0, 4, 180, 68, 82, 65, 71, 95, 66, 67, 79, 69, 70, 95, 88, 0, 0, 0, 0, 4, 15, 89, 0, 0, 0, 0, 4, 73, 77, 95, 78, 83, 69, 0, 0, 0, 63, 0, 4, 58, 67, 79, 69, 70, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]}
55: GLOBAL_POSITION_INT {time_boot_ms : 417459, lat : 0, lon : 0, alt : -4920, relative_alt : -4921, vx : 0, vy : 0, vz : 0, hdg : 3330}
55: GPS_RAW_INT {time_usec : 0, fix_type : 0, lat : 0, lon : 0, alt : 0, eph : 65535, epv : 65535, vel : 0, cog : 0, satellites_visible : 0, alt_ellipsoid : 0, h_acc : 0, v_acc : 0, vel_acc : 0, hdg_acc : 0, yaw : 0}
86: HEARTBEAT {type : 11, autopilot : 3, base_mode : 65, custom_mode : 0, system_status : 4, mavlink_version : 3}
55: HWSTATUS {Vcc : 5043, I2Cerr : 0}
55: MCU_STATUS {id : 0, MCU_temperature : 3587, MCU_voltage : 3306, MCU_voltage_min : 3296, MCU_voltage_max : 3314}
55: MCU_STATUS {id : 0, MCU_temperature : 3587, MCU_voltage : 3306, MCU_voltage_min : 3296, MCU_voltage_max : 3314}
55: MEMINFO {brkval : 0, freemem : 65535, freemem32 : 631936}
1: MISSION_COUNT {target_system : 255, target_component : 230, count : 2, mission_type : 0}
55: MISSION_CURRENT {seq : 0, total : 0, mission_state : 0, mission_mode : 0}
2: MISSION_ITEM_INT {target_system : 255, target_component : 230, seq : 1, frame : 3, command : 16, current : 0, autocontinue : 1, param1 : 0.0, param2 : 0.0, param3 : 0.0, param4 : 0.0, x : 468059848, y : -712453723, z : 100.0, mission_type : 0}
2: PARAM_VALUE {param_id : STAT_RUNTIME, param_value : 134868.0, param_type : 6, param_count : 836, param_index : 65535}
55: PID_TUNING {axis : 4, desired : 0.0, achieved : 0.0, FF : 0.0, P : 0.0, I : 0.0, D : 0.0, SRate : 0.0, PDmod : 0.0}
55: PID_TUNING {axis : 4, desired : 0.0, achieved : 0.0, FF : 0.0, P : 0.0, I : 0.0, D : 0.0, SRate : 0.0, PDmod : 0.0}
55: POWER_STATUS {Vcc : 4941, Vservo : 0, flags : 17}
55: RAW_IMU {time_usec : 417619670, xacc : 241, yacc : 183, zacc : -950, xgyro : -6, ygyro : 1, zgyro : 1, xmag : 0, ymag : 0, zmag : 0, id : 0, temperature : 4528}
55: RAW_IMU {time_usec : 417619670, xacc : 241, yacc : 183, zacc : -950, xgyro : -6, ygyro : 1, zgyro : 1, xmag : 0, ymag : 0, zmag : 0, id : 0, temperature : 4528}
55: RC_CHANNELS {time_boot_ms : 417579, chancount : 0, chan1_raw : 0, chan2_raw : 0, chan3_raw : 0, chan4_raw : 0, chan5_raw : 0, chan6_raw : 0, chan7_raw : 0, chan8_raw : 0, chan9_raw : 0, chan10_raw : 0, chan11_raw : 0, chan12_raw : 0, chan13_raw : 0, chan14_raw : 0, chan15_raw : 0, chan16_raw : 0, chan17_raw : 0, chan18_raw : 0, rssi : 255}
55: RC_CHANNELS_SCALED {time_boot_ms : 417800, port : 0, chan1_scaled : 0, chan2_scaled : 0, chan3_scaled : 0, chan4_scaled : 0, chan5_scaled : 0, chan6_scaled : 0, chan7_scaled : 0, chan8_scaled : 0, rssi : 255}
55: SCALED_IMU2 {time_boot_ms : 417659, xacc : 222, yacc : 181, zacc : -945, xgyro : 1, ygyro : 1, zgyro : 0, xmag : -124, ymag : -116, zmag : 294, temperature : 4400}
55: SCALED_PRESSURE {time_boot_ms : 417700, press_abs : 993.890625, press_diff : 0.0, temperature : 3264, temperature_press_diff : 0}
55: SERVO_OUTPUT_RAW {time_usec : 417559633, port : 0, servo1_raw : 0, servo2_raw : 0, servo3_raw : 0, servo4_raw : 0, servo5_raw : 0, servo6_raw : 0, servo7_raw : 0, servo8_raw : 0, servo9_raw : 0, servo10_raw : 0, servo11_raw : 0, servo12_raw : 0, servo13_raw : 0, servo14_raw : 0, servo15_raw : 0, servo16_raw : 0}
55: SERVO_OUTPUT_RAW {time_usec : 417559633, port : 0, servo1_raw : 0, servo2_raw : 0, servo3_raw : 0, servo4_raw : 0, servo5_raw : 0, servo6_raw : 0, servo7_raw : 0, servo8_raw : 0, servo9_raw : 0, servo10_raw : 0, servo11_raw : 0, servo12_raw : 0, servo13_raw : 0, servo14_raw : 0, servo15_raw : 0, servo16_raw : 0}
15: STATUSTEXT {severity : 6, text : IMU0: fast sampling enabled 2.0kHz, id : 0, chunk_seq : 0}
55: SYSTEM_TIME {time_unix_usec : 0, time_boot_ms : 417800}
55: SYS_STATUS {onboard_control_sensors_present : 321969167, onboard_control_sensors_enabled : 320897039, onboard_control_sensors_health : 34636043, load : 47, voltage_battery : 18951, current_battery : 3, battery_remaining : 99, drop_rate_comm : 0, errors_comm : 0, errors_count1 : 0, errors_count2 : 0, errors_count3 : 0, errors_count4 : 0}
8: TIMESYNC {tc1 : 0, ts1 : 410819613001}
55: VFR_HUD {airspeed : 0.0, groundspeed : 0.0, heading : 33, throttle : 0, alt : -4.869999885559082, climb : -0.0}
55: VIBRATION {time_usec : 418000093, vibration_x : 0.007128438446670771, vibration_y : 0.00808044895529747, vibration_z : 0.0075416602194309235, clipping_0 : 0, clipping_1 : 0, clipping_2 : 0}
reboot
MANUAL>
M0fAP: Calibrating barometer
INITIALISING> Mode INITIALISING
AP: Barometer 1 calibration complete
AP: Beginning INS calibration. Do not move vehicle
MANUAL> Mode MANUAL
AP: ArduPilot Ready
AP: AHRS: DCM active
AP: RCOut: PWM:1-16
Time has wrapped
Time has wrapped 3798 432119
AP: EKF3 IMU0 initialised
AP: EKF3 IMU1 initialised
AP: EKF3 IMU0 tilt alignment complete
AP: EKF3 IMU1 tilt alignment complete
AP: EKF3 IMU0 forced reset
AP: EKF3 IMU0 initialised
AP: EKF3 IMU0 tilt alignment complete
fence list
MANUAL> No geo-fence points

As you can see, noise problem is gone. With the configuration I have now, do you think I am using miniUart instead of PL011 Uart? Right now, the equivalences of ports (serial VS tty) is shown below:

Thanks again for all your replies!

To disable the shell, I used sudo raspi-config.