Additional sensor

Hello community members.

I want to attach an additional sensor to the Raspberry Pi 3 + NAVIO2 pair which sends numerical data using UART. I’d like to be able to transmit the additional sensor’s data using the data link and see it in Mission Planner or Qgroundcontrol. What do you recommend as the most easy way to accomplish it (hardware and software recommendations)? I can program using C/Python on the Raspberry Pi, or change Ardupilot’s code if necessery and recompile it.


It depends on a sensor type. Please be a little more precise :slight_smile:

Yes of course, it’s a custom sensor which must be connected using UART. You just send a START command and then it starts sending numbers 5 times a second until you send it STOP command:

< 66
< 67
< 66
< 68
< 65

I want to send the data along with the data that NAVIO2 is sending (like GPS) to the ground using the telemetry modem. If 5p/s is too fast (I don’t think it is) I can average the data and send it for example at 1p/s.

Thank you for your interest.

I suggest taking a look at user hooks feature and a newer AP_Module dynamic library support.

Thanks a lot, it seems like just what I want.

I’m looking into the AP_Module option. There are those hooks that can be used:


I don’t see a place where I can insert additional data into the MAVLink data stream. So it seems I must use the former option (hooks in the code instead of a stand-alone module) and recompilation will be needed.

What about the hardware part? If I use a USB radio instead of UART Radio can I use the freed-up UART port for the communication with the custom sensor from the Raspberry Pi?

Sure. Or the other way around.

It seems like you’ll need to add a new MAVLink message or use another data stream option (another radio, UDP, TCP and so on). Otherwise, there’s a risk of an interference on the channel which is not a good thing for sure.

Thank you Mr. Staroselskiy, you are very helpful.

If you don’t mind, just a one more question.

We have programming experience (system + embedded) but we are not familiar (yet) with the Ardupilot source code, the MAVLink protocol and the general scheme how things work. As I understand there is a closed source firmware on the STM32F103 part which communicates to the sensors and controls, but it acts only as a dumb proxy between Ardupilot and the hardware:

Ground <-> MAVLink through Modem <-> Ardupilot (brain) on Raspberry <-> MAVLink through UART? <-> Firmware on STM32 <-> Sensors + Controls

Am I correct?

Now I’m supposed to inject an additional MAVLink message from Ardupilot to Ground. Can you give general directions in the Ardupliot (copter) source code? Where (in what files) to add the definition of the new messages and how to send them? How to make Qgroundcontrol/Mission Planner show them?

Another maybe easier option will be to change an existing message that is being shown on Qgroundcontrol/Mission Planner and I don’t care about.

Your help is very much appreciated. In case of success we are planning to purchase at least 5 more NAVIO2 devices.

It’s not quite right. The RCIO coprocessor handles only RCInput, ADC and PWM generation. All other stuff is in ArduPilot using Linux API.

It’s not that complicated and documented here. Feel free to ask anything you don’t understand!

Basically here’s all you’ll need:

  • generate a new message with the instructions provided above
  • add an initialization hook in ArduPilot sourcecode
  • read and send the data on the regular basis. Take a look at this entry to grasp what you need to do.

I hope I’m being helpful! We’ll continue trying help you solve all the issues you might encounter.

Thank you so much again, you are being very helpful, I’ll come back in couple of days with the results (hopefully) and the code, or maybe with more questions :slight_smile: