How to create a custom telemetry item to display in HUB

I’ve developed a script that runs on a Raspberry Pi and sends custom data to Mission Planner, such as Wi-Fi signal quality. However, I’m currently limited to sending data to pre-existing items like “battery_temp” and “rssi”. I’d like to create my own custom items, for instance, “signal_quality” or “network_type”. Can anyone guide me on how to establish a custom item in Mission Planner?

Look into NAMED_VALUE_FLOAT (#251). It’s already handled by ArduPilot and Mission Planner.

Your information is very vague. As I mentioned in the topic, I am familiar with both NAMED_VALUE_FLOAT and NAMED_VALUE_INT, but I need them to appear in the Status as Custom Items. Do we have a step-by-step guide on how to customize and actually make it work?

Simply send a valid named float message, and it should become available when you double click the Quick tab, so far as I know. If it does not, perhaps try prefixing your custom name with “MAV_”

Hi Yuri,

I’ve created a Python script named “send.py” with the code provided. The custom item “MAV_MOBILE_NET” appears in the list, but the value consistently displays as “0”. Do you have any idea what might be causing this?

CODE:
from pymavlink import mavutil
import time

def send_named_value_float(mav, name, value):
“”“Send a NAMED_VALUE_FLOAT message.”“”
# Get the time_boot_ms as the time difference since the first received heartbeat
time_boot_ms = int((time.time() - mav.start_time) * 1000)

# Ensure the name is exactly 10 bytes long
encoded_name = name.encode('ascii').ljust(10, b'\0')

mav.mav.named_value_float_send(time_boot_ms, encoded_name, value)

def main():
# Create TCP connection
mavlink_connection_string = “tcp:127.0.0.1:5760”
mav = mavutil.mavlink_connection(mavlink_connection_string)
print(f"Connected to {mavlink_connection_string}")

# Wait for a heartbeat to ensure connection to the vehicle
mav.wait_heartbeat()
print("Heartbeat received!")

# Send the NAMED_VALUE_FLOAT message with name "mobile_net" and value 133.0
send_named_value_float(mav, 'mobile_net', 133.0)
print("Message sent!")

if name == “main”:
main()

Hello everyone,

Is there anyone here well-versed with the MAVLink protocols and Mission Planner? Could someone replicate the code on their setup and let me know if the value also displays as “0” for you?

I’ve attached a screenshot for reference. As you can see, when using the MAVLink Inspector, the value displayed is correct at 133.33. However, in both the HUB and QUICK sections, the value shows as “0”.

Thank you for your assistance!

you should send it continuously, be not just once. Every 1-2 second is fine

send it with sysid 1 and compid 1 !

Hi Eosbandi, thanks for your time.

I’ve modified the code to send the message repeatedly every 0.5 seconds, but the value still appears as “0”. Are you certain you’ve had this working before? It seems to me there might be a bug in the handling of Custom Messages.

I am running this code on a Raspberry Pi , is connected via serial to the ArduPilot, and Mission Planner is running on my Windows machine.

New Python Code:

from pymavlink import mavutil
import time

def send_named_value_float(mav, name, value):
“”“Send a NAMED_VALUE_FLOAT message.”“”
# Get the time_boot_ms as the time difference since the first heartbeat received
time_boot_ms = int((time.time() - mav.start_time) * 1000)

# Ensure the name is exactly 10 bytes long
encoded_name = name.encode('ascii').ljust(10, b'\0')

mav.mav.named_value_float_send(time_boot_ms, encoded_name, value)

def main():
# Create a TCP connection
mavlink_connection_string = “tcp:127.0.0.1:5760”
mav = mavutil.mavlink_connection(mavlink_connection_string)
print(f"Connected to {mavlink_connection_string}")

# Wait for a heartbeat to ensure it's connected to the vehicle
mav.wait_heartbeat()
print("Heartbeat received!")

try:
    # Loop to send the message every 0.5 seconds
    while True:
        # Send the NAMED_VALUE_FLOAT message with name "mobile_net" and value 133.0
        send_named_value_float(mav, 'mobile_net', 133.0)
        print("Message sent!")
        time.sleep(0.5)  # Wait for 0.5 seconds before sending the next message
except KeyboardInterrupt:
    # Handle any cleanup or resource releasing if necessary
    print("Interrupted by user, stopping message sending.")

if name == “main”:
main()

Hello, has anyone managed to get the custom message feature working? I’m currently facing some issues. The value in the HUB remains at ‘0’.