[SOLVED]MPU6050 and Arduino Uno

We are using a MPU6050 gyrometer/accelerometer for a balancing robot. We want to use Serial.available for receiving steering commands from a nodemcu or computer, the problem though is that while using Serial.available we receive FIFO overflow from the MPU6050 as it takes to long time. How can we solve this problem both receiving integers written in serial monitor or from a Nodemcu and using the MPU6050 sensor at the same time?

We want to use Serial.available for receiving steering commands

That won't work - you must use Serial.read to receive commands. Serial.available simply tells you how many characters are available to read.

We are using serial.read within the serial available function, I forgot to mention that.

But we still can't see the code you forgot to mention

We are using serial.read within the serial available function

Really?

I have said that we are using serial.read within the serial available function, and the problem is that it takes to long time reading it from the buffer which causes a problem for the MPU6050 buffer.

int nr;
if (Serial.available() > 0) {
    nr = Serial.read();
}

Then we have a switch case for the steering commands.

I have said that we are using serial.read within the serial available function,

What you have posted does not show that you are using read within available.

What you have posted does not give anyone enough to help you with your problem.

Stop responding with unnecessary posts, the problem is not with the code but solving how to use serial read at the same time as using the MPU6050 without getting FIFO overflow. An other solution may be to connect the MPU6050 to another Arduino which could communicate through serial communication with the arduino which steers the motors. But does the serial.read also cause problem for the loop-time (time for it to go through the loop) and then also cause problem with PID?

Please stop responding with information-deficient posts.

To answer your question (and if you had engaged your brain for a moment, you could have answered your own question), of course Serial.read will cause the loop to slow down (by a few microseconds), but whether or not this is enough to disrupt your PID timing ONLY YOU CAN ANSWER, BECAUSE WE CANNOT SEE YOUR CODE, OR KNOW ANY OF ITS TIMINGS.

Maybe it is not the Serial.read itself that slows things, but some further time-consuming calculation what it reads entails, but we can't tell, because we cannot see your code.

Now, quit the Jedi mind-tricks, and post the goddamn code.

the problem is not with the code

Well, if it isn't the code, what is it, duh?

Will you (the OP) please give view of your h/w and s/w setup in the following style?

The robot is equipped with MPU6050 which is connected with a local Arduino UNO having a Bluetooth Module. This is the slave UNO (UNO-2). There is a Command Station composed of PC, UNO-1 and Bluetooth. Communication between UNO-1 and UNO-2 happens via BT.

The signal processing is done in UNO-2. The UNO-1 receives error signals form UNO-2 and accordingly sends steering commands to UNO-1 which regulates the movements of the robot. and etc. etc.

We solved the problem by not using Serial Communication. Instead we came up with an idea that make it whole lot easier for us, that we could use digitalRead on the Arduino analog ports (four ports, forward, backward, left, right) and the NodeMCU could just send HIGH or LOW to each port for the steering.
Thanks anyway for responding.

Congratulations - you just made my blacklist.