I am trying to use the MPU6050 sensor in a vertical position, (i.e. with the Y-axis aligned with gravity and perpendicular to the ground), and thus acquire the rotation data (yaw) on this axis.
I know that the Z-axis suffers drift in the MPU6050, because it does not have a magnetometer. I also know that Euler Angles suffer from Gimbal Lock.
But I was using Jeff Rowberg’s code (i2cdevlib/Arduino/MPU6050 at master · jrowberg/i2cdevlib · GitHub), which uses quaternions, but I’m still stuck in this job.
I tried to change the MPU6050_6Axis_MotionApps20.h file, for the Y axis to become vertical, following these instructions from another forum: Change default axes orientation - MPU-6050 6-axis accelerometer/gyroscope (InvenSense) - I2Cdevlib Forums, but without success. When I rotate the Y-axis, already positioned vertically, I don’t receive correct data, when " #define OUTPUT_READABLE_YAWPITCHROLL " is uncommented. I also tried to uncomment " #define OUTPUT_READABLE_QUATERNION " and see what happens, but incorrects values came too (when I rotate the sensor and stop it, the values change, but a little bit after the previous values come back).
However, I also tried to use Teapot output, unccomenting " #define OUTPUT_TEAPOT ", of Jeff’s code, and using Processing software, I was able to rotate the MPU6050 and the graphic output (airplane) was responding correctly!
My problem is: I need the vertical axis rotation data, when the MPU6050 is arranged vertically. So, when the MPU6050 is positioned vertically, I need the Y-axis rotation data. This is my problem.
If the Teapot works correctly, why can’t I get the correct data from Euler Angles or Quaternions?
Can someone help me? Thanks in advance!
My code (.ino file) is attached here!
MPU6050DMP6.ino (17 KB)