VL53L3X interfacing problem with nrf52832

Hii , I am interfacing VL53L3X sensor with the nrf52832 , and using its given liberary which is in zephyr  for VL53L0X , as I think it should we work with also my sensor VL53L3x , I use the given liberary and connect my device and check on the logic analyser the graph is generated , its means the I2C communication is stabelist , but I got error  device not ready. ,


if any one done this interfacing give me the idea  or details,

This is my code which i am using 

main.c

/*
 * Copyright (c) 2017 STMicroelectronics
 *
 * SPDX-License-Identifier: Apache-2.0
 */

#include <zephyr/kernel.h>
#include <zephyr/device.h>
#include <zephyr/drivers/sensor.h>
#include <stdio.h>
#include <zephyr/sys/printk.h>
#include <zephyr/drivers/i2c.h>

#define I2C0_NODE DT_NODELABEL(st_vl53l0x)
int main(void)
{
    const struct device *const dev = DEVICE_DT_GET_ANY(st_vl53l0x);
    struct sensor_value value;
    int ret;

    if (!device_is_ready(dev)) {
        printk("sensor: device not ready.\n");
        return 0;
    }

    while (1) {
        ret = sensor_sample_fetch(dev);
        if (ret) {
            printk("sensor_sample_fetch failed ret %d\n", ret);
            return 0;
        }

        ret = sensor_channel_get(dev, SENSOR_CHAN_PROX, &value);
        printk("prox is %d\n", value.val1);

        ret = sensor_channel_get(dev,
                     SENSOR_CHAN_DISTANCE,
                     &value);
        printf("distance is %.3fm\n", sensor_value_to_double(&value));

        k_sleep(K_MSEC(1000));
    }
    return 0;
}




.overlay

&pinctrl {
    i2c0_default: i2c0_default {
        group1 {

            psels = <NRF_PSEL(TWIM_SDA, 0, 26)>,
                    <NRF_PSEL(TWIM_SCL, 0, 27)>;
        };
    };

    i2c0_sleep: i2c0_sleep {
        group1 {

            psels = <NRF_PSEL(TWIM_SDA, 0, 26)>,
                    <NRF_PSEL(TWIM_SCL, 0, 27)>;
            low-power-enable;
        };
    };

};

&i2c0 {
    compatible = "nordic,nrf-twim";
    status = "okay";
    clock-frequency = <I2C_BITRATE_FAST>;
    zephyr,concat-buf-size = <4096>;

    vl53l0x: vl53l0x@29 {
        compatible = "st,vl53l0x";
        reg = <0x29>;
        label = "VL53L3CX";
    };

};


.prj

CONFIG_STDOUT_CONSOLE=y
CONFIG_I2C=y
CONFIG_GPIO=y
CONFIG_SENSOR=y
CONFIG_VL53L0X_PROXIMITY_THRESHOLD=100
CONFIG_PRINTK=y
#debug
#CONFIG_DEBUG=y
#CONFIG_LOG=y
#CONFIG_SENSOR_LOG_LEVEL_DBG=y
CONFIG_CBPRINTF_FP_SUPPORT=y

 

Parents
  • Hello,

    In the overlay you provided, the device address for the vl53l0x sensor is set to 0x29. 

    Please make sure that the device address specified in your code matches this address. If your sensor has a different address, you will need to update it.

    The device not ready message can be because of a connection issue or the sensor not being powered properly.

     

    Kind Regards,

    Abhijith

Reply
  • Hello,

    In the overlay you provided, the device address for the vl53l0x sensor is set to 0x29. 

    Please make sure that the device address specified in your code matches this address. If your sensor has a different address, you will need to update it.

    The device not ready message can be because of a connection issue or the sensor not being powered properly.

     

    Kind Regards,

    Abhijith

Children
  • I had use address for this sensor is 0x29 , while in the given address in the dataseat is 0x52, Here is the reason for this , when i use the 0x52 address and use logic analyser its show nothing, and when i used 0x29 its show the graph . after that I used i2c scanner on arduino for this sensor the result was also 0x29, thats why I am using this address. 

Related