Reverse engineering undocumented MPU6050 registers

I'll start by sharing my findings on the FINE_GAIN registers, which are (from I2Cdev library):

#define MPU6050_RA_X_FINE_GAIN      0x03 //[7:0] X_FINE_GAIN
#define MPU6050_RA_Y_FINE_GAIN      0x04 //[7:0] Y_FINE_GAIN
#define MPU6050_RA_Z_FINE_GAIN      0x05 //[7:0] Z_FINE_GAIN

Sensors usually have to be calibrated by the following equation:
real value = (reading_from_sensor - offset) * scaling_factor

The offset registers are known and often used, but I have never seen anyone using the registers for the scaling factor. After long nights of frustration I came to the following conclusion:

Bits 0-3 affect the gyro values
Bits 4-7 affect the accelerometer values

These registers do have factory calibration values, but like the accelerometer offsets, they are often way off. I have not done anything to gyro scaling, as I have no means to verify rotational speeds. However since we know gravity we can easily verify accelerometer readings.

First step is to calibrate the accelerometer offsets (values are in +-16g mode). If you have done a good job, accelerometer readings will be exactly the same if you flip it over up side down, except for the sign of course.

After this set the gain register to 0 and take a new reading, with the positive axis facing up. The new correct offsets (4 bits) can be calculated with the following formula.
scaling_factor = (2048 - accel_reading) / 29

To find the divisor I just plotted the accelerometer readings and changed the fine gain value. With each step (there are 16 steps) the readings approximately change by 29 in average (somewhere in the range of 28-30). This is a floating calculation and when converting to integers you have to round up or down.

Of course this has to be done for each axis, carefully placing the sensor to get the highest readings possible when not moving.