# MPU6050 gyroscope giving wrong measure

i am trying to make an angle meter, using the UNO and MPU6050, following joop brokking video tutorials,

when utilizing the accelerometer, the results are fine,

however when i try to use gyroscope (each one alone) do not get the expected result

when rotating the sensor from 0 to 90 degrees, the output change from 0 to 60~70 degrees only

so what is wrong is it the code, the gyroscope is damaged

here is the code

 refresh ();
angle += (gyro_x - cal_x) * (millis () - timer) / 1000.0;
Serial.println (angle);


refresh (); is a function that updates gyro_x

the MPU6050 is fixed so that it rotatea in one direction only

later on i took this false measure and applied it in a complementary filter, the result was plausible, and varies around 0.5 degrees, i still need to get it to an accuracy of 0.0x

This will be a bit troublesome to help with, as you didn't post all of your code or more importantly your exact errors (Serial.print()), but for general infos, and for others it's enough. Questions regarding troubleshooting your wiring/c code directly, I think should be directed to arduino.stackexchange.com There are countless questions and answers there.

You need to integrate the gyro if you plan on getting an angle...

An example code (in wiring) to integrate your gyroscope readings would be, with 0.01 being your sampling constant $$\Delta t$$

void update_int(double *u, double *y)
{
static double x[1] = {0};
double x1[1];
y[0] = x[0];
x1[0] = x[0] + 0.01*u[0];
x[0] = x1[0];
}


However keep this in mind, gyros are accurate short term, but long term have 'drift' and will become unreliable.