Adding the VL53L1X Driver to an STM32Cube Project

Hello @690969913,

Looking at the attached STM32Cube project, you’ve got your I2C pins (PB6 and PB7) configured as GPIO outputs. You need to enable the I2C peripheral (in this case, I2C1) as was done in Step 2 of the “Creating an STM32Cube Project” procedure outlined above. Since you want to use PB6/PB7 instead of the default PB8/PB9 you will then need to remap the I2C function to those pins. This is easy to do using the drag-and-drop method described in Section 4.5.5 “Manually remapping a function to another pin” in the STM32CubeMX User Manual (UM1718).

EDIT:
Ok, looking further into the project, I see you’re trying to incorporate Alientek’s version of the driver which uses a bit-banging approach. If you wish to continue along that path, then please disregard the above comment. However, since you are utilizing an MCU with I2C functionality, I would suggest taking advantage of it. Perhaps try creating a new project from scratch and following the tutorial as written, making only the necessary modifications for your hardware connection constraints. Bit-banging is very slow and typically only used as a last resort.

Also, I don’t think you should be connecting VCC3.0 to the 3V3 pin of the F1 board. Looking at the flow module schematic, VCC3.0 is a power output pin. +BATT is your power input.

1 Like

Thank you very much for your answer. I will try again based on your suggestions.