The purpose of this library is to make a basic and lightweight interface for the MPU6050. It can do the following:

  • Configure the inbuilt low pass filter
  • Configure the sensitivity of the accelerometer and gyro
  • Retrieve the raw output of the sensor
  • Output scaled accelerometer and gyro values

The library includes two functions to calibrate the gyro and remove bias. The first is intended to be called when the sensor is turned on and is not moving. It takes a long term average of the output of each axis and subtracts these values from the raw signals.

The second function is designed to update the averages. It updates the values with a moving average and the gain is controlled by something akin to a kalman filter. By polling this function one can correct for drift in the gyro bias. By combining these two functions one can obtain stable and consistent gyro outputs. However, The accelerometer needs to calibrated manually by correcting the bias and scale.

Finally, the library was written for a single MPU6050 connected to a MEGA board as follows. It may require some modifications to work succesfully on other boards:

image

See this link for the information on the registers of the MPU6050: MPU 6050 register map

Github Repo:

basicMPU6050