Being able to connect to PX4 via Serial is essential for development. It allows you to run individual apps in PX4 and it provides a straight forward interface for debugging. I have successfully connected to a HK Pilot 32 using a FTDI breakout adapter in Ubuntu, and here is how I did it.
A quick summary:
- Connect FTDI cable and USB cable
- Install putty, launch and configure
- Run some applications
1. Connect FTDI cable
PX4 serial connection works a bit different than Ardupilot. If you connect your Pixhawk to the computer via a micro USB cable, you will only see gibberish in the console. The correct way is to use the serial port on Pixhawk and connect to the computer via a FTDI cable. A FTDI cable is something like this:
The breakout adapter is the same as the cable, except you need to bring your own micro USB cable to connect it to the computer. The tricky part is to get the pin out match correctly.For the serial connection you only need three wires, the RX, TX and GND.
The complete setup is shown below.
The official guide can be found here: PX4 serial connection
So far I have only successfully connected a Pixhawk/HK Pilot 32 to Ubuntu. I haven’t found a way to connect a Pixfalcon to the console, as there is no serial port.
Update: it turns out you can connect to serial via micro USB cable if you remove the micro SD card.
2. Install putty, launch and configure
There are many serial console applications on Ubuntu (e.g. screen, minicom, piocom etc.). Putty is the preferred application in UAB lab. To install putty, open a terminal window, and type:
sudo apt-get install putty
If it is installed correctly, launch putty by using the command (use the sudo prefix to make sure you have access to all the ports):
Now you should see a window like this:
The key configurations here are connection type and serial line as circled in red. For connection type choose Serial. The serial line is usually /dev/ttyUSB0 or /dev/ttyACM0 on Linux. If you want to check which one is it you can type “ls /dev/tty*” in the terminal before and after you plug in the cable, and see which one has changed. You can save your session by clicking the save below so you don’t have to configure every time you launch putty.
Now click open at the bottom to start the session. You should see a new window with title “/dev/ttyXXXX – PuTTY”.
3. Run some applications
To check if your connection is established successfully, type “help” into the PuTTY console. If you see something like the screen shot below, congratulations! You can also play around some of the Builtin Apps from help, such as “tone_alarm” and “rgbled”.