How to connect two VL53L0X distance sensor with two different I2C connection

I alredy connected one sensor and its running , but i need to connect another sensor which will be connected in parallel to the other sensor.Can anyone help me about this problem?VL53LOX.txt (37.9 KB)
here is the code for single connection.

Hello.

The recommended way to use multiple VL53L0X on the same I2C bus involves an initialization process where you initially drive the GPIO0/CE chip enable pin low to disable every sensor except the first one. You can change the address of the first sensor to something other than the default, then release CE on the next sensor (which will start up with the default address) and change it to another unique address, continuing in sequence until you have assigned each sensor a unique address. This is explained in more detail in ST’s AN4846 application note.

If you have trouble implementing that in your sketch, you can try simplifying your code to the simplest version that shows the issue, post it here, and I can take a look.

-Jon

Hello Jon,
Thanks for your reply , from last three day i try to connect my sensor to my micro controller but some how i was not able to connect and i couldn’t change the address.I am using a PSOC4 MC( CY8CKIT-049-42xx)…I also didn’t find this VL53L0x_SINGLE_DEVICE_DRIVER macro in VL53LOX.h file.I really dont understand hoe to change the address.Now i try to change 1st sensor address.Can you please screen short step by step how to do that.I am sending the picture of my connection and the whole code file.May be you can have a look on it and suggest me how to do this.Thanks again for your help.
Asif


Main.c.txt (2.3 KB)
VL53L0X.h (5.9 KB)
VL53LOX.c.txt (37.9 KB)d
I send you all my files , please have a look and let me know where should i chang my code to Chang the address.
Thanks,
Asif

Could you show us a version of your code that does work with a single sensor, like you mentioned in your first post?

-Jon

Hello Jon,
Yes sure.here is main.c file of my code Main.c (1.9 KB)
here is VL53LOX.c file VL53LOX.txt (37.9 KB)
and here is VL53LOx.h file VL53L0X.h (5.9 KB)

If there is a single sensor how i will change the address of that single sensor?The default address which is 0x29.

A few of us looked at your code and didn’t see anything obvious wrong with it. Unfortunately, if the second program you posted works but the first one does not, we are not sure what the problem is, and we are not familiar enough with your microcontroller platform to offer detailed advice about working with it. It looks like the library you are using was adapted by Vlad Rădoiu from our original Arduino library, so you might try asking him for help if you have not already.

By the way, even if you do manage to get a single sensor working, I am not sure you will be able to use multiple sensors with this library. Our original library was written in C++ (Arduino) and used objects to keep track of different sensor instances, but the library you are using has been converted to C and uses a global variable to keep track of the sensor address, so there seems to be no way for it to keep track of more than one sensor, although you could ask Vlad if he has gotten it to work some other way.

-Jon