Cannot read distance after I2C address is changed. VL53L1X time of fight sensor
Hello,
I'm currently working with the VL53L1X distance sensor on the nRF52. I'd like to use two of them with te same i2c busses. Therefore, I need to change the address of one of these.
I have successfully used a single sensor (using the default address 0x29). Now I want to change the address of this sensor (still using a single sensor), but when I try to read the distance, I get error -13.
The I2C address is correctly changed, because i do get this new address when I read the I2C address buffer (0x0001). Also, my logic analyser confirms that the new i2c address is used, but the read/write command is not acknowledged (so no distance is read of cource).
I looked to the api and logic analyser results in more detail, and I added the following line in the function VL53L1_init_and_start_range() (from vl53l1_api_core.c):
if (i2c_index == 0x001 && buffer[0] == 0x29 && Dev->I2cDevAddr != 0x29) { buffer[0] = Dev->I2cDevAddr; }
(This line changes default i2c address (0x29) to the correct one, but only when data is written to the i2c index of the i2c_slave__device_address (0x0001))
This new line results in a success while reading the distance, but this should not be the correct way of doing this.
So my question is: What is going wrong after I changed the i2c address? And how can I fix this?
Also, is it possible to change the i2c address if I only use one vl531x?
if there is any information missing, please tell me.
