Problem using parallel a sensor with I2C and a motor with a Timer (PWM)

The Sensor is connected to the Pins 20 (SDA) and 21 (SCL) to the 3.3V and to GND.

Two problems here:

  1. Your sensor operates on 3V3 and your arduino is giving him 5V on the I2C lines (the Wire library activates the internal weak pullups). Some sensor may be fried by that, your's seem to be quite tolerant but still you have only the weak pullups (if I remember correctly about 20k).
  2. If you insert pullups (2k2) to 3V3 you have the correct value for the sensor but you're at the limit (60-70% of VCC means logical 1, so for 5V it's 3V-3V5).

The correct solution is to insert a level converter (Logic Level Converter - Microcontroller Accessories Interface - Boxtec Onlineshop).

Putting your motor to higher speed means it consumes more current and probably the voltage drops a bit. This may be enough to disable the internal pullups to put the I2C lines to a HIGH level within an acceptable time frame. A few misses on the SCK line may be enough to let your Arduino wait forever for an answer from your sensor.