I'm using MPU6050(accelerometer+gyro) connected to ATmega328P microcontroller, but probably it isn't even important in my case.
In my project, I need an angle around the X axis. And it's calculated like this:
angle = -(atan2(acc.XAxis, sqrt(acc.YAxis*acc.YAxis + acc.ZAxis*acc.ZAxis))*180.0)/M_PI;
where acc is vector of accelerations in all directions.
The problem is, that it gives me credible value only when angle between Z axis and ground is right (so it's not rotated around Y axis). When I start to rotate it around Y axis it also changes value of X axis rotation.
I know, that it's due to YAxis acceleration in my algorithm, but I have no idea how to get rid of it.
How can I solve this problem?