2024-07-03 03:17 AM - last edited on 2024-07-23 08:40 AM by Amel NASRI
I am trying to connect two VL53L8CX time of flight sensors to STM32F401RET6. I need one I2C bus for both sensors but unable to assign slave address dynamically. I need to know where to modify the program in stm32cube IDE
2024-07-23 10:02 AM
The trick is to have LPn low on one of your sensors. This way it's not paying attention to bus. Then issue the address change command to the one sensor that is paying attention.
Create 2 'Dev' structures. I like an array of dev structures.
With one sensor in reset (LPn low) init the first sensor and change it's address. Then make sure you change the I2c address in the 'Dev[0]' structure.
Then bring the LPn up on the second sensor and init as usual with Dev[1].
That should do it.
-john
2024-07-23 10:21 PM
2024-07-24 07:56 AM
yes it's possible. but in your code once you have configured the initial sensor to be 62 don't mess with its LPn line!
just bring the other sensor out of reset and initialize it. There will be no confusion. you will have one at 52 and one at 62.
it's that shut_sensor1(); that is killing you. it just reset the sensor you so carefully set up.
And I'm not a fan of having a Sensor1 and a sensor2, when you access them with i=0 and i=1.
It's just me, but it reminds me fondly of my early Fortran days, before they invented arrays that started with 0. 🙂
- john
2024-07-24 10:31 PM
I am actually using X-NUCLEO-53L8A1 expansion boards. Only one board can be Active at a time on the bus[power enable and LPN pins]. The second sensor will not be initialized without shutting the first one. We did try what you suggested but it did not work!!
2024-07-25 12:16 PM
Ah - There is a bug in the initial set of blue boards for the VL53L8 that makes causes a failure when connecting a satellite board.
You can either wait until the new versions come out or you can have a look at:
an5945-how-to-connect-the-satelvl53l8-to-an-stm32-nucleo64-board-stmicroelectronics (2).pdf
This app note will show you how to connect 1 satellite board to your Nucleo. With a little soldering you can connect the second one. (I know I make it sound easier that it is - and it's somewhat messy as well.)
There is an App Note on this issue, but I'm having trouble finding it.