MPU6050 stops working when I turn on motor ps

Hello, im having some problems with mpu6050. It works okay until i plugin in my stepper power source and then the MPU gets strange readings (incorrect angle measures) and i2c communication breaks after a few seconds.
Is it possible that 30-40cm of arduino jumper wires is too long for i2c communication? Or should I look for the source of my problems elsewhere?

Thanks for help.

I've eliminated wire lenght as the source of the problem because this still happened when MPU was connected to the arduino with only a short wire.
Does anyone know what else could the problem be? The mpu communication still breaks when i turn on the motor power supply. I drew up the system, maybe someone can help me now, thanks.

It might be a ground problem. All the grounds need
to connect together.
Dwight

Hi, thanks for answering. We tried to connect the 2 grounds together, the results did not change.

I would check and make sure that it isn’t emf interference from the stepper. Have you tried it with the mpu6050 some distance away from the stepper?

What chip are you using for the H bridge?
Dwight

Hi, sorry for answering late. MPU is about 20cm away from the stepper, and I'm using pololu a4988 driver for the stepper.