MPU6050 big error after moving

Hi!
I'm using the MPU6050_light library. It is working pretty good so far but I have noticed a problem. When I wiggle and move the sensor really fast and then put it back into its original position I gain a huge offset on one axis.


Does anyone know why this is?

Hi,
What are the lines displayed? What data is each representing? Could you post your code?

Yeah sure! I'm using the GetAngle example from the library.

#include "Wire.h"
#include <MPU6050_light.h>

MPU6050 mpu(Wire);
unsigned long timer = 0;

void setup() {
  Serial.begin(9600);
  Wire.begin();
  
  byte status = mpu.begin();
  Serial.print(F("MPU6050 status: "));
  Serial.println(status);
  while(status!=0){ } // stop everything if could not connect to MPU6050
  
  Serial.println(F("Calculating offsets, do not move MPU6050"));
  delay(1000);
  // mpu.upsideDownMounting = true; // uncomment this line if the MPU6050 is mounted upside-down
  mpu.calcOffsets(); // gyro and accelero
  Serial.println("Done!\n");
}

void loop() {
  mpu.update();
  
  if((millis()-timer)>10){ // print data every 10ms
	Serial.print("X : ");
	Serial.print(mpu.getAngleX());
	Serial.print("\tY : ");
	Serial.print(mpu.getAngleY());
	Serial.print("\tZ : ");
	Serial.println(mpu.getAngleZ());
	timer = millis();  
  }
}

It shows you the angle on the x,y and z axis.

Hi,
This example code is meant to be used with serial monitor, not serial plotter. That could be part of the problem. Try this:

#include "Wire.h"
#include <MPU6050_light.h>

MPU6050 mpu(Wire);
unsigned long timer = 0;

void setup() {
  Serial.begin(9600);
  Wire.begin();
  
  byte status = mpu.begin();
  //Serial.print(F("MPU6050 status: "));
  //Serial.println(status);
  while(status!=0){ } // stop everything if could not connect to MPU6050
  
  //Serial.println(F("Calculating offsets, do not move MPU6050"));
  delay(1000);
  // mpu.upsideDownMounting = true; // uncomment this line if the MPU6050 is mounted upside-down
  mpu.calcOffsets(); // gyro and accelero
  //Serial.println("Done!\n");
}

void loop() {
  mpu.update();
  
  if((millis()-timer)>10){ // print data every 10ms
	//Serial.print("X : ");
	Serial.print(mpu.getAngleX());
	//Serial.print("\tY : ");
	Serial.print(mpu.getAngleY());
	//Serial.print("\tZ : ");
	Serial.println(mpu.getAngleZ());
	timer = millis();  
  }
}

Just tried and I can see the same thing in the serial monitor. In the beginning it is showing 0 and after fast movement it is showing a big offset.

The MPU6050 is a 6DOF sensor, which can measure the two Euler tilt angles, pitch and roll, using the accelerometer, but cannot measure yaw (rotation about Z). A 9DOF sensor is used for that.

Here is an overview of Euler angles: http://www.chrobotics.com/library

Is there any way to work around that problem?

Hi,
Not really. You could use a mpu9250 instead.

Ok thanks for the answers. Thankfully I only need pitch and roll for my project. But I've done some more research and I just want to make sure I get it right. You get the pitch and roll angle by looking at gravitation and the accelerometers, right? And most MPU6050 libraries try to get the proper yaw value by integrating the rate of change? So when I move it too fast the sensor is too slow to determine the right rate of change? When I move it slowly it works as it should and gives me somewhat reliable results... Is what I said correct?

The MPU-6050 cannot measure yaw.

It can only integrate the rate of rotation about Z, using an arbitrary starting value, and that process is very noisy and inaccurate.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.