cancel
Showing results for 
Search instead for 
Did you mean: 

vl53l5cx i2c address change

BPutt.1
Associate II

Hi,

I have two vl53l5cx sensors in my system. I need to change (at least one) of the device addresses. I used the instructions from n UM2884, section 2.3, that is.

  1. Power up the system.
  2. Reset the sensor by LPn pin LOW, I2C_Reset HIGH, wait 500msec, LPn pin High, I2C_Reset LOW. wait 500msec.
  3. LPn pin LOW of all bu the selected device.
  4. Call vl53l5cx_set_i2c_address with the new address.
  5. status |= platform.WrByte(config.vl53L5CX_Device, 0x7fff, 0x02); will result in 255.

What could be wrong here?

1 REPLY 1
Anne BIGOT
ST Employee

Hello Bob,

I don't know what could be wrong but what I could suggest is to have a look to the code shared within the X-Cube-TOF1 package here and check for the MX_53L5A1_MultiSensorRanging_Init function description in the 53L5A1_MultiSensorRanging example. It could help to port the code.

Anne

static void MX_53L5A1_MultiSensorRanging_Init(void)

{

 uint8_t device;

 uint16_t i2c_addr;

 uint32_t id;

 /* Initialize Virtual COM Port */

 BSP_COM_Init(COM1);

 printf("53L5A1 Multi Sensor Ranging demo application\n");

 reset_all_sensors();

 /* Turn off all the sensors */

 for (device = 0; device < RANGING_SENSOR_INSTANCES_NBR; device++)

 {

  write_lowpower_pin(device, GPIO_PIN_RESET);

 }

 /* initializes each device and put it in low power mode */

 for (device = 0; device < RANGING_SENSOR_INSTANCES_NBR; device++)

 {

  /* enable only one sensor */

  write_lowpower_pin(device, GPIO_PIN_SET);

  HAL_Delay(2);

  status = VL53L5A1_RANGING_SENSOR_Init(device);

  if (status != BSP_ERROR_NONE)

  {

   printf("VL53L3A2_RANGING_SENSOR_Init %d failed\n", device);

   ToF_Present[device] = 0; /* device not detected */

  }

  else

  {

   ToF_Present[device] = 1; /* device detected */

  }

  write_lowpower_pin(device, GPIO_PIN_RESET); /* turn off the device */

 }

 /* power on the devices one at a time and change their address

  * once the address is updated, the communication with the devices is checked

  * reading its ID.

  */

 for (device = 0; device < RANGING_SENSOR_INSTANCES_NBR; device++)

 {

  /* skip the sensor if init not successful */

  if (ToF_Present[device] == 0) continue;

  /* turn on the device */

  write_lowpower_pin(device, GPIO_PIN_SET);

  /* left: 0x54, center: 0x56, right: 0x58 */

  i2c_addr = (RANGING_SENSOR_VL53L5CX_ADDRESS + (device + 1) * 2);

  VL53L5A1_RANGING_SENSOR_SetAddress(device, i2c_addr);

  /* check the communication with the device reading the ID */

  VL53L5A1_RANGING_SENSOR_ReadID(device, &id);

  printf("ToF sensor %d - ID: %04lX\n", device, (unsigned long)id);

 }

}


Our community relies on fruitful exchanges and good quality content. You can thank and reward helpful and positive contributions by marking them as 'Accept as Solution'. When marking a solution, make sure it answers your original question or issue that you raised.

ST Employees that act as moderators have the right to accept the solution, judging by their expertise. This helps other community members identify useful discussions and refrain from raising the same question. If you notice any false behavior or abuse of the action, do not hesitate to 'Report Inappropriate Content'