MATLAB Answers

[SOLVED] How to send serial data over Telemetry Radio (PX4 Autopilots Support from Embedded Coder)

234 views (last 30 days)
Joshua O'Reilly
Joshua O'Reilly on 12 Jul 2019
Commented: R on 14 May 2020
I followed the Serial/UART tutorial here and everything worked fine; I can send data over USB using the Serial interface. I then based myself off of the getAccelerometerData.m file to test passing data back and forth between the Holybro Telemetry Radios while both are connected to my laptop; I've attached the .m file here. I've also attached the Simulink model.
My challenge is sending the same data, but between the Pixhawk 4 and my laptop (where one telemetry radio is plugged into the pixhawk and the other is plugged into my laptop); even though the LED indicator on the radios indicate they're communicating (which they do when I open QGroundControl), I can't get any kind of data to transfer over them. I've tried using both the TELEM1 and UART & I2C B ports on the Pixhawk (and changed the corresponding Simulink Model parameters to communicate over /dev/ttyS1 or /dev/tttyS4. I've verified that I selected both the appropriate port on my laptop, and on the Pixhawk, and tried different combinations, to no avail. In short:
Does anyone know how to allow data transfer over the Telemetry Radios between the Pixhawk and my laptop?
I'm running Windows 10 1809, Ubuntu 16.04 WSL, Pixhawk 4 with latest firmware (v1.9.0, I think), MATLAB R2018b, and the Telemetry Radios have been flashed using QGroundControl with the latest firmware.
Edit: This is literally something that is recommended to try in the Simulink documentation here: Configure the PX4 Serial Transmit and Receive model to exchange data over other serial ports of the Pixhawk Series controller.
So how do I actually do that?


Show 1 older comment
Joshua O'Reilly
Joshua O'Reilly on 25 Jul 2019
What port are you using on the Pixhawk 4 and what radio hardware?
Just spamming data, I can connect over USB, but trying to run the exact same program over TELEM1 using the telemetry radios fails to send data (using the two attached, super simple programs). I'm using the Holybro telemetry radio set, but I also rigged up a APC220-43 radio, also with no success.
Joshua O'Reilly
Joshua O'Reilly on 26 Jul 2019
I wired a USB to UART adaptor to the UART & I2C B port on the Pixhawk 4; still nothing. even with a physical connection. That makes me think it's the actual Simulink code that's unable to access it. Maybe the old PSP manual has some info on this.
Joshua O'Reilly
Joshua O'Reilly on 26 Jul 2019
From the Pixhawk Support Package from 2016, p.62 of the PDF:
I think it's entirely possible that this still isn't fixed, and so wireless communication over telemetry radios just isnt' possible.
My Recommendation at this point:
Get a Raspberry Pi, attach it to via USB and then wireless transmit the information wherever

Sign in to comment.

Accepted Answer

Joshua O'Reilly
Joshua O'Reilly on 26 Jul 2019
The Cause
You can't use telemetry radios. Back in 2016, the Pixhawk Support Package indicated:
Important Note: Recent testing has confirmed that external mode does not operate correctly with the telemetry radios. Data comes in very sporadiaclly and in long intervals. We are looking into this and will provide an update to address the issue, in the maen-time, please use USB for serial connection for external mode.
Since I still can't do this, I can only assume that they didn't fix it/implement it in the latest version.
The "Solution"
Use an companion computer, such as a Raspberry Pi, as indicated in the PX4 documentation. Hook that up via USB, and then transmit wireless between the Raspberry Pi and whatever device you were originally trying to connect to.
This really is unfortunate, as the goal, for me, was to create my simulink model, upload it to the Pixhawk, and have it communicating with my laptop. Now, I need to write a custom serial receiver AND either WiFi/SSH/Serial sender on the Raspberry Pi as well.


Edward Bruce
Edward Bruce on 28 Jan 2020
Hey Joshua,
Just wanted to let you know I had a similar problem with the esp8266 telemetry wifi module. I currently have it connected to Telem2 and solved the issue by adding the following lines to the end of the rc.txt file on the sd card:
mavlink start -d /dev/ttyS2 -b 921600 -m onboard -r 80000
mavlink boot_complete
If you want to use if with telem1 just change /dev/ttyS2 to /dev/ttyS1
hopefully this can help you out!
Joshua O'Reilly
Joshua O'Reilly on 30 Jan 2020
I added the lines to the rc.txt and still nothing. I'm assuming I need to switch from sending a "raw" serial message to sending mavlink messages?
R on 14 May 2020
if you want to send your custom data from simulink you can't use the telem1,telem2 ports , as you said ,it wont work .
I dont know why , but using Serial4/5 of pixhawk1 or GPS2 port on pixhawk2(cube) does allow sending youre custom data with telemtry unit by using the "Serial Transmit' block.
"Edward Bruce" sugestion , allows you to get MAVLINK base default data , not yours custom data

Sign in to comment.

More Answers (0)