Guide to gyro and accelerometer with Arduino including Kalman filtering

ok thanks for your reply
my fault I should have made it clearer: when I asked if it could be measured, I meant the ANGLE...not the acceleration

It's clear (sort of :slight_smile: ): you can't measure yaw with the accelerometer...but I was thinking with the gyro...and as you said you can.
in Fact at the end of your code you are only calculating x and y angles and not Z angle...is there are reason why?

compAngleX = (0.98*(compAngleX+(gyroXrate*dtime/1000)))+(0.02*(accXangle));
  compAngleY = (0.98*(compAngleY+(gyroYrate*dtime/1000)))+(0.02*(accYangle));
  xAngle = kalmanCalculateX(accXangle, gyroXrate, dtime);
  yAngle = kalmanCalculateY(accYangle, gyroYrate, dtime);

Can the same concept be extended to the Z angle?

compAngleZ = (0.98*(compAngleZ+(gyroZrate*dtime/1000)))+(0.02*(accZangle));
zAngle = kalmanCalculateZ(accZangle, gyroZrate, dtime);

Moreover...when you say "keep calibrating the zeroValue"
you mean that after the previous calculation I set the
gyroZeroZ = zAngle? so I keep calculating incremental angle variation?ù
or do you mean to take out the comments to the line

gyroZangle=gyroZangle+gyroZrate*dtime/1000;//Without any filter

why did you leave that commented? it wasn't working?

Anyhow, thanks a lot for the help :slight_smile:
if you ever need a quick hand drawn sketch (dirty and quick) just ask :wink:

cheers
b.