cancel
Showing results for 
Search instead for 
Did you mean: 

Changing VL53L5CX i2c address?

VBhat.1
Associate III

Hi, I am trying to use the vl53l5cx_set_i2c_address() function in order to change the i2c address, but it keeps returning -2, or VL53L5CX_COMMS_ERROR from the following line in vl53l5cx_set_i2c_address():

status |= WrByte(&(p_dev->platform), 0x7fff, 0x02);

The WrByte seems to fail. I would like to change the i2c address, in order to use multiple modules, but currently I can only use one. Any suggestions or advice would be appreciated. Thanks!

11 REPLIES 11
Peter BENSCH
ST Employee

Sorry, that was a wrong statement, because 0x52 is just the default address that can of course be changed: The I2C address of the VL53L5CX is permanently preset in the sensor and cannot be changed. If you want to address several sensors, you have to separate them logically, e.g. with an I2C bus switch.

Good luck!

If the problem is resolved, please mark this topic as answered by selecting Select as best. This will help other users find that answer faster.

/Peter

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
VBhat.1
Associate III

<deleted>

Hi Peter, thanks for replying! If the VL53L5CX can't have it's i2c address changed, what does the vl53l5cx_set_i2c_address() function mentioned in the documentation and vl53l5cx_api.c file do?

It refers to pulling down LPn pins of all other devices not having their i2c address changed, and using set_i2c_address, then pulling LPn of other devices back high, and so forth until all devices have different addresses set.

Sorry, I made a wrong statement. Now it is time to check why you are getting an error.

Regards

/Peter

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Did you follow the guidelines in UM2884, section 2.3?

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Yes, right now I have only connected 1 VL53L5CX device to my i2c bus, and have LPn pulled high. The WrByte(&(p_dev->platform), 0x7fff, 0x02); in set_i2c_address still fails (returns 254), but I'm not sure exactly what it's doing. After the code fails I can't connect to the VL53L5CX again until I cycle power.

Should set_i2c_address be called before or after VL53L5CX_init()? Currently I am doing it after.

After I get the comms error status from the set_i2c_address function, using i2cdetect on my raspberry pi I can indeed see that the i2c address of the VL53L5CX has changed to my intended value, I just am not able to communicate with it at that address.

Hi Peter, do you have any more ideas as to how to set the i2c address? Has anyone else been able to do so successfully yet?