hi i got VL53L1X Time-of-Flight Distance Sensor
becuse this sensor dont have static adress i connect the to pi zero
can i make code with mavsdk that set the rngdnd data directly?

So you want to feed the distance sensor data into PX4? That’s not supported by MAVLink or MAVSDK as far as I’m aware.

What do you mean? Here I read:

  • Default I2C address 0x29 (can be changed in software by using shutdown pin to disable other sensors on the same bus)

i try connect more then one VL53L1X
VL53L1X is lidar that px4 and arsupilot support but this lidar isnt have static address. need to gavr to each sensor a adress with another pin…
so i try connect it to pi zro and then to gave the data to the pixhwak

Ok, and the feature to change the IDs by this device don’t work? How many are you trying to connect?

to change the ids with this device is with another pix the - xshut pin
i dont understand how to to this with the flight controler only

i can gave the range finder the data from my pi

from mavsdk import System, telemetry
import asyncio
import board
import digitalio
import adafruit_vl53l1x

class RangefinderDrone:
    def __init__(self):
        # Initialize serial connection
        self.system = System()
        self.telemetry = telemetry.Telemetry(self.system)
        self.I2c = board.I2C()

        # Initialize VL53L1X sensors
        self.vl53l1x = [adafruit_vl53l1x.VL53L1X(i2c) for i2c in self.I2c]

        # Start ranging for VL53L1X sensors
        for sensor in self.vl53l1x:

    async def connect(self):
        print("Connecting to drone...")
        # Connect to drone using the serial port
        await self.system.connect(system_address="serial:///dev/ttyAMA0")

    async def rng_give_drone_data(self):
        while True:
            await asyncio.sleep(1)  # Adjust sleep duration as needed
            for idx, sensor in enumerate(self.vl53l1x):
                distance_data = self.read_rangefinder_data(idx)
                await self.telemetry.send_distance_sensor(sensor)  # Send distance sensor data to the drone

    def read_rangefinder_data(self, idx):
        # Placeholder method to read data from rangefinder at index idx
        # Replace this with your actual code to read rangefinder data
        return {
            'minimum_distance': 0.1,  # Replace with actual minimum distance
            'maximum_distance': 10.0,  # Replace with actual maximum distance
            'current_distance': self.vl53l1x[idx].range / 1000,  # Current distance in meters
            'sensor_id': idx  # Replace with actual sensor ID
        #print(self.vl53l1x[idx].range / 1000)

async def main():
    drone = RangefinderDrone()
    await drone.connect()
    await drone.rng_give_drone_data()

if __name__ == "__main__":

somthing like that

(tzadok_venv) navkit@raspberrypi:~ $ python3 set_data_rng_to_pixhwak.py 
Traceback (most recent call last):
  File "/home/navkit/set_data_rng_to_pixhwak.py", line 52, in <module>
  File "/usr/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
  File "/usr/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
  File "/usr/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
    return future.result()
  File "/home/navkit/set_data_rng_to_pixhwak.py", line 47, in main
    drone = RangefinderDrone()
  File "/home/navkit/set_data_rng_to_pixhwak.py", line 11, in __init__
    self.telemetry = telemetry.Telemetry(self.system)
  File "/home/navkit/tzadok_venv/lib/python3.11/site-packages/mavsdk/_base.py", line 10, in __init__
  File "/home/navkit/tzadok_venv/lib/python3.11/site-packages/mavsdk/_base.py", line 17, in _init_plugin
AttributeError: 'System' object has no attribute 'channel'
Exception ignored in: <function System.__del__ at 0xb45682a8>
Traceback (most recent call last):
  File "/home/navkit/tzadok_venv/lib/python3.11/site-packages/mavsdk/system.py", line 88, in __del__
  File "/home/navkit/tzadok_venv/lib/python3.11/site-packages/mavsdk/system.py", line 124, in _stop_mavsdk_server
ImportError: sys.meta_path is None, Python is likely shutting down

This doesn’t look right. You have to connect before using the plugisn. And you don’t initialize telemetry like that. Where did you get the code from? To me it looks like a mix of the C++ and the Python API.

Have a look at the examples when in doubt: