Ultrasonic sensor info from Arduino to Pixhawk 2

Hi!

How to send sonar / Ultrasonic sensor information from Arduino to Pixhawk 2 using MAVLink?

What is the best way to do it? Is it possible to write to a correct parameter?

All the Best

I think you would be using this MAVLink message:
https://mavlink.io/en/messages/common.html#DISTANCE_SENSOR

We have dug little bit further. The plan right now is to connect Pixhawk 2 Telem 2 port through level shifter to an Arduino Mega board.

Ultrasonic sensors are connected to the Arduino Mega and we are able to read the distance information.
Now the idea is to send this information to Pixhawk 2 / PX4 using MAVLink messages.

So we found a similar project for Arduino side, where the guy is reading multiple sensors and sending out MAVLink messages. The code can be found here:

The PX4 software side is still unclear. We would like to write straight to distance sensor information (I think the Arduino software is doing that already).
So how do we see if the messages are arriving and how to use them from Pixhawk side?
How do I configure the distance sensors?

You can add a printf in mavlink_receiver.cpp where the MAVLink message is arriving that you’re sending. That way you know it’s arriving. Before that make sure that the MAVLink communcation is configured correctly between Arduino and Pixhawk (see: Redirecting to latest version of document (master)).

Good question. @mrivi do you know?

@boga what do you need to do with the range data?