MPU6050 accel/gyro noise that behaves strangely - what might be doing this?

Errors look like +/-256 +/- expected drift.

This suggests some kind of synchronising error - such as reading the LSByte of one sample and the MSByte of the next or vice versa. How does your gyro handle this, is there some way to temporarily put it on hold while you read data?

Also, examine the raw data around a few of these errors to see if it happens when a slowly drifting signal crosses an MSByte boundary. Obviously, focus on the Y Gyro, the errors are most clearly separated from the noise.


@BrianDrummong identified the source of the apparent noise in the accepted answer. Reading one byte at a time over I2C resulted in asynchronous behavior so that the hi and lo bytes corresponded to different conversions. Using bus.read_i2c_block_data() solved the latching problem. By reading fourteen bytes (seven words) (three accelerometers, temperature, three gyroscopes) as a single I2C instruction, the "noise" has disappeared.

def read_sevenblock():

    # read fourteen bytes starting at address 0x3b. This will cycle through
    # ax, ay, az, temp, gx, gy, and gz

    fourteen_bytes = bus.read_i2c_block_data(0x68, 0x3b, 14)  # Read them all at once

    his, los       = fourteen[0::2], fourteen[1::2]  # high bytes are first

    values = []
    for hi, lo in zip(his, los):
        value  = (hi << 8) + lo            # combine high and low byte
        if value >= 0x8000:
            value = -((65535 - value) + 1)   # convert signed negative values 
        values.append(value)
    return values

enter image description here