How to detect distance sensor in Visual Studio Code 2019?

Вадим Белых 20 Reputation points
2023-08-14T10:38:41.2166667+00:00

Sensor VL 53-400

Developer technologies | C#
0 comments No comments
{count} votes

Accepted answer
  1. Sander van de Velde | MVP 36,761 Reputation points MVP Volunteer Moderator
    2023-08-17T12:22:52.02+00:00

    Hello @Вадим Белых ,

    based on your comments, you are using a USB version of this sensor.

    I found this community library with samples:

    Vl53L0X vL53L0X = new Vl53L0X(I2cDevice.Create(new I2cConnectionSettings(1, Vl53L0X.DefaultI2cAddress)));
    Console.WriteLine($"Rev: {vL53L0X.Information.Revision}, Prod: {vL53L0X.Information.ProductId}, Mod: {vL53L0X.Information.ModuleId}");
    while (!Console.KeyAvailable)
    {
        try
        {
            Console.WriteLine($"Distance: {vL53L0X.Distance}");
        }
        catch (Exception ex)
        {
            Console.WriteLine($"Exception: {ex.Message}");
        }
        Thread.Sleep(500);
    }
    

    Take some time to figure out how the library works and how to tweak it for the best result and good error-catching.


    If the response helped, do "Accept Answer". If it doesn't work, please let us know the progress. All community members with similar issues will benefit by doing so. Your contribution is highly appreciated.

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Sander van de Velde | MVP 36,761 Reputation points MVP Volunteer Moderator
    2023-08-14T11:51:40.5466667+00:00

    Hello @Вадим Белых ,

    This sensor will probably be used with a constrained device like an Arduino.

    Because it has an I2C bus connection, it can be used on a Raspberry PI too.

    There are libraries and code samples available as seen here.

    Most of the documentation will point you to the Arduino IDE which is ok.

    For Visual Studio code, an extension is available:

    User's image

    So you probably code on an RPI or you have an Arduino (or eg. ESP32) connected and deploy your code to that device.

    As an alternative, you could also use Azure IoT Edge and roll out a custom container talking to the sensor over the I2C bus.


    If the response helped, do "Accept Answer". If it doesn't work, please let us know the progress. All community members with similar issues will benefit by doing so. Your contribution is highly appreciated.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.