I2C bus stuck after enable/disable I2C master mode

You took a deep dive, but even without touching the water with my big toe, I can feel that something is wrong.

First of all, this is not how to solve a problem. You need a I2C device that is known to be good and working and you need a library that is known to work with that I2C device.
Then it is important to make small steps.
Let a I2C Scanner run for hour and keep track of all the misses.
Then try to read the WHO_AM_I register.

Your STM32 core is not by Arduino.
Arduino has the Nicla Vision with a STM32. For that board, the Arduino software layer is on top of Mbed. It has its own variant here: https://github.com/arduino/ArduinoCore-mbed/tree/main/variants/NICLA_VISION

Your ESP32 core is also not by Arduino but by Espressif. That is no problem, it reliable and good.

Can you show a photo, so we can see the wiring: if you use 3.3V or 5V, if there is a voltage regulator on the sensor module that drops the voltage for the sensor too much, if there are pullup resistors or maybe too much pullup, how your grounding is, and so on.

Could you to upgrade to Arduino 2.1.1 ?

Do you see that I'm still miles away from the details that you gathered ? Your sensor chip could be running at 2.3V with the wrong amount of pullup. You could even have a flat ribbon cable with SDA next to SCL :scream: