Please provide procedure to use ToF sensor library VL53L1X in VS Code nRF Connect SDK.

Hi,

I am working on a project that involves using Time of Flight sensor VL53L1X with nRF9160. I have nRF9160DK and I am building my project in VS Code. 

I have tried adding following lines in prj.conf. 

CONFIG_I2C=y
CONFIG_NEWLIB_LIBC=y
CONFIG_SENSOR=y
CONFIG_DT_HAS_ST_VL53L0X_ENABLED=y
CONFIG_VL53L0X=y
CONFIG_VL53L0X_PROXIMITY_THRESHOLD=100
When I compile the project I am getting error w.r.t "CONFIG_DT_HAS_ST_VL53L0X_ENABLED." Below is the error message.
"error: DT_HAS_ST_VL53L0X_ENABLED (defined at
C:/nordicsemi/MyApps/TESTAppV0.1/build_1/Kconfig/Kconfig.dts:4962) is assigned in a configuration
file, but is not directly user-configurable (has no prompt). It gets its value indirectly from other
symbols. See docs.zephyrproject.org/.../kconfig.html
and/or look up DT_HAS_ST_VL53L0X_ENABLED in the menuconfig/guiconfig interface. The Application
Development Primer, Setting Configuration Values, and Kconfig - Tips and Best Practices sections of
the manual might be helpful too."
Kindly help me to solve this issue. 
 
  • Hi,

    The Kconfig option CONFIG_DT_HAS_ST_VL53L0X_ENABLED cannot be set in prj.conf. This option is automatically enabled when VL53L1X is enabled in devicetree.
    To fix this, remove CONFIG_DT_HAS_ST_VL53L0X_ENABLED and create a devicetree overlay file where you add VL53L1X. It should look something like this, make sure to set correct I2C and reg for your project:

    &i2c2 {
        vl53l0x: vl53l0x@30 {
        compatible = "st,vl53l0x";
        reg = <0x30>;
        };
    };

    Best regards,
    Marte

  • Hi Marte, 

    Your suggestion works for VL53L0X ToF sensor. I am working on VL53L1X which has different interface.

    I tried replacing vl53l0x with vl53l1x in overlay file and prj.conf file. It didn't work. Does nRF SDK V2.3.0 provide drivers for VL53L1X? 

  • Hi,

    I based it on your configurations, as they are for VL53L0X.

    I have tried adding following lines in prj.conf. 

    CONFIG_I2C=y
    CONFIG_NEWLIB_LIBC=y
    CONFIG_SENSOR=y
    CONFIG_DT_HAS_ST_VL53L0X_ENABLED=y
    CONFIG_VL53L0X=y
    CONFIG_VL53L0X_PROXIMITY_THRESHOLD=100

    There is support for the VL53L1X, see st,vl53l1x (on i2c bus). This was added recently, so it is only on the main branch of nRF Connect SDK currently. The configs and devicetree will be very similar to vl53l0x:

    CONFIG_I2C=y
    CONFIG_NEWLIB_LIBC=y
    CONFIG_SENSOR=y
    CONFIG_VL53L1X=y

    &i2c2 {
        vl53l1x: vl53l1x@30 {
        compatible = "st,vl53l1x";
        reg = <0x30>;
        };
    };

    Best regards,
    Marte

Related