Problem with I2C

Hi I’m trying to use the MPU6050 connected to I2C2 port on an Esp32 DevKitC. There are also other sensors and a pump. Sometimes, it gives me an InvalidHardwareStatusError, but not always. In particular, in the text of the exception it is written “wifi not started”. I have connected the MPU to I2C2, it shouldn’t give me problem. How can I solve?

could you try running your I2C code without the wifi module completely?
Then run it with the wifi driver connected to a wifi network? to see the behavior.

The code of the device I2C runs perfectly alone.
When I try the entire project without the wifi driver it seems not to throw the exception.
With the wifi driver sometimes it throws the exception, after activated and turned off the hydro pump.
At the moment the only idea I had was to put the operation of read from the I2C device in a try except block…
Another question, if I have two I2C device, one on the I2C1 port and the other on the I2C0 port, can I start the communication with one of them without calling the ‘stop’ function on the other one?

I have read some posts about ESP32 that when wifi is on, the power consumption is much higher, maybe that interfers with the I2C bug.
Could you try to power the ESP32 devKit with external power source, maybe an AC/DC power adapter.
Then if this is not the issue, we will eliminate this option and look for other reasons.

They should run simultaneously with no interference with each other.

I tried but now it doesn’t enter in the main loop. In particular it throws a TimeoutException in the function start, followed by the ‘wifi not started’. The exception is thrown from the function write of the built in i2c library.
I though I’ve written bad the driver, but the driver itself runs. And also using the Vcc and Gnd from the board shared with other sensors it doesn’t give me problem. In this case, using the wifi module, the error seem to be aleatory, it isn’t thrown always

Can it be a problem caused by wifi signal? For example, the board disconnect automatically from a wifi network and throws the InvalidHardwareStatusException?

We need to replicate the error to debug it.
to make sure I understand, The I2c code works as expected without wifi, then if the wifi is connected the I2c throws InvalidHardwareStatusException?

Just by connecting another stable, regulated power source, the code doesnot work anymore?