MPU 6050 crashes with my sketch

bms001:
I believe that if the FIFO is overflowing then you need to read it more often, or detect the overflow and clear it.

You can change the FIFO refresh rate in line 305 of the MPU6050_6Axis_MotionApps20.h file:

    0x02,   0x16,   0x02,   0x00, 0x01                // D_0_22 inv_set_fifo_rate

For information on detecting overflow and clearing the FIFO (if that's what you need to do ) I would look at the I2CDev library first and then also the MPU6050 datasheet.

You are using the pulseIn function

roll_channel = pulseIn(ch1, HIGH);

This may be where your issue is coming from. In general use of this function is discouraged for time critical applications since this function blocks the program from doing anything else while it it measuring, and waiting for, the pulse. It would be best to to use interrupts to measure these pulses instead.

Try removing all the pulseIn statements from your code and checking if you are still getting the FIFO overflow.

Although looking at your code, are you reading the MPU at all? The example that I think you have based this code on relies on receiving an interrupt from the MPU when it populates the FIFO buffer, but in your setup() it looks like you have removed the attachInterrupt(...) and other lines.

Have you used this approach to read the MPU only (i.e. without any other functionality included) and did that work?

Hi bms001, the mpu 6050 works even though the interrupt function is removed. The pulseIn function is needed to allow me to take in the pulse from the receiver and sent it to the flight controller even though I removed the pulseIn function as mentioned I wasn't able to receive the result from the MPU 6050 and it kept printing "FIFO overflow".