Sending data from companion computer to GCS through pixhawk

Its pretty much what its in the subject, I tried searching in the forums, but all of the other similar post nobody asked so I am trying again, hopping for someone to help

Just send Mavlink messages to the FC, they will get forwarded to the GCS.

for example, I have already used all of the uarts in my fc, then I use the ones on my companion computer, to send to the GCS, is as simple as just making the data from sensor into a mavlink message and just send it?

Not all messages are supported of course, so you will need to do some testing, but yes, reuse the FC <-> companion computer link that you have.

So I am planning to use this fuel sensor connected to a RPI. I know I can connect directly to a cube, but for my project I need to use it connected to a RPI.

From what I researched and what you said, I just need to create this mavlink message( using the data from sensor and send through the connection rpi has with cube?

yeap, that should work fine.

I have a need to monitor the level in a chemical tank on a pull-behind trailer. I will be interested in how well that sensor works for you.

Thank you for the answer. Now I just need to figure out how to write the code for making this BATTERY_STATUS message and then to send to pixhawk

use pymavlink to generate the C or C++ code for you.

I am reading this page: to learn the functions from pymavlink, but from what I saw they didn’t show an example with a function to send message, the closest being sending a command

@amilcarlucas could explain how could I do that? I thought I had to take the functions from the mavlink libaries and write the code

The code from the mavlink libraries has been generated by pymavlink.
All you need to do is call the existing function for that particular message. And if you do not have the libraries yet, you can generate them using pymavlink generator.

Hello, I managed to generate the libraries from the dialect. Now I reading the mavlink documents on how to use them

So after reading, the ardupilotmega has a method, battery_status_send(), and since its already in ardupilotmega, i don’t need to make any modifications.

So I just need to import mavutils, connect the raspberry pi to pixhawk, input the values into the battery_status_send() and then done, at least its what I think. Is this right @amilcarlucas?

yes, I think so. Keep us posted on the results

yeah, I got it, managed to send the battery_status data from the raspberry to pixhawk, and through mavlink inspector, it arrived at mission planner

1 Like

So I did this and moved to other tasks and now back to it I noticed that although I could check in mavlink inspector that data arrived, I now noticed I didn’t check if it could be retrieved.

When I send the message from my companion computer and then check the mavlink inspector, there is two vehicles, #1 with lots of messages, and #255 with only heartbeat and the message I am sending.

If I attach another device to this mavlink stream and try to retrieve the information from the message, I receive the #1 vehicle’s message instead of #255.

Since the data can be seen at mavlink inspector, there must be a way to extract it, right?

255 is the GCS
1 is the vehicle

yeah and dronekit source system by default is 255 too, but my point is that dronekit retrieves information from #1 instead of whatever number I put as source system for my rpi. I am asking if there is a way to retrieve specifically from rpi from another end.If it was possible to specify the target system when creating the vehicle object during connection it would be perfect.

is there some way to do this, like modifying a part of the code of dronekit or pymavlink?