MAVLink and Arduino: step by step

Is there a way to determine what component a heartbeat has came from?

as far as i can see the mavlink library only gives you the type

 heartbeat->custom_mode = mavlink_msg_heartbeat_get_custom_mode(msg);
    heartbeat->type = mavlink_msg_heartbeat_get_type(msg);
    heartbeat->autopilot = mavlink_msg_heartbeat_get_autopilot(msg);
    heartbeat->base_mode = mavlink_msg_heartbeat_get_base_mode(msg);
    heartbeat->system_status = mavlink_msg_heartbeat_get_system_status(msg);
    heartbeat->mavlink_version = mavlink_msg_heartbeat_get_mavlink_version(msg);

source component id is part of the message so there should be a method for that though it may be a separate function as it is message independent.

Hi, @geofrancis:
Yes, the sysid and compid are in the message structure. Just get it after parsing the message. You have all the details here.
KR

1 Like

Did you not have to use a level shifter to connect the Arduino to the Pixhawk? I thought you need one since the Arduino uses 5V logic and the Pixhawk uses 3.3V logic.

Hi, @GABRIEL_ROMERO:

No, I didn’t need level shifters in my setup. Even if logic levels are different, the Pixhawk is “5v tolerant”, so you can feed directly 5v to the GPIOs. On the Arduino side, 3.3v is enough to trigger the “true/high” state, thus no level adapting is needed. I insist, in this particular setup.

If using a different microcontroller you should carefully review what pins (if any) are “5v tolerant” even if they work with 3.3v logic levels.

KR

Hey, nice post sir, I am coming after some time here, so i dont know what matter is currently ongoing , i just came and read the first post,

so, my question is, why do we need an arduino to control the lights? Cant the latest FCs control the lights using the “aux” pins programmed by lua script? Wouldnt an on drone arduino or a companion computer consume heavy amounts of power?

As i am a learning beginner, getting just a little time and money for this hobby,
Please feel free to tell anything extra also.

Hello, @RudrakshTek:

The topic is about learning how to use MAVLink. The Arduino and the lights are just an excuse…

KR,
Juan Pedro

1 Like