Guide to gyro and accelerometer with Arduino including Kalman filtering

You have to include this in the setup() function:

  //calibrate all sensors in horizontal position
  gyroZeroX = calibrateGyroX();
  gyroZeroY = calibrateGyroY();  
  gyroZeroZ = calibrateGyroZ();
  
  accZeroX = calibrateAccX();
  accZeroY = calibrateAccY();
  accZeroZ = calibrateAccZ();

If you look in the original code it is there!
Also it would be a good idea to change:

int gyroZeroX;//x-axis
int gyroZeroY;//y-axis
int gyroZeroZ;//z-axis
int accZeroX;//x-axis
int accZeroY;//y-axis
int accZeroZ;//z-axis

To float values, as this will give higher precision.

I do not know why the code you linked to does not work. Try downloading the original software again from my post, as this works! Then when you have it up and running modify the code for your needs :slight_smile: