I'm doing a project with the MPU6050 accelerometer. First I calculate the offsets of the MPU only once executing the sketch of Luis Ródenas.
Later, once I get the offsets, I copy them into the configuration of a second sketch and I always execute it with the same values.
//Placa casa MPU6050 viejo
//-1172 -873 1351 76 -758 27
accelgyro.setXAccelOffset(-1172);
accelgyro.setYAccelOffset(-873);
accelgyro.setZAccelOffset(1351);
accelgyro.setXGyroOffset(76);
accelgyro.setYGyroOffset(-773);
accelgyro.setZGyroOffset(33);
The problem I have is that after a time of having executed the second sketch several times, the raw readings present a new offset.
I read that this problem can be by the temperature of the sensor, that it is necessary to compensate the readings with the temperature. But I can not find an example to do so. I wanted to ask if anyone knows what the problem might be and how I can fix it.
I see two ways to deal with MPU6050 temperature drift:
setup()
, so you will get the valid offset parameters on each device start, no matter, what is the temperature of device. This method is used in multirotor flight controller to calibrate its IMU, which is often based on MPU60x0. Write sketch which do:
Serial
with current T.Now cool down the MPU6050 in the freezer, and then put it into hot environment (50degC should be enough; depends on which T range the final device will be used) and start calibration sketch.
Now, having a table [T]->[offsets]
your can adjust original sketch to monitor the T of MPU6050 and once it changes, assign the corresponding offsets to MPU6050.