Question about reading data from the MPU6050

Hello everybody!

I have a question for you. I just started using the MPU6050 gyroscope and accelerometer and I'm having some trouble. I read a little bit the documentation and watched a lot of videos and tutorial, but I'm having an issue.

Here's my code :

#include "Arduino.h"
#include "Wire.h"

const int MPU_ADDR = 0x68;

int16_t gyro[] = {0, 0, 0};

void setup_mpu() {
  Wire.begin();
  Wire.beginTransmission(MPU_ADDR);
  Wire.write(0x6B);
  Wire.write(0x00);
  Wire.endTransmission();
}

void print_gyro() {
  Wire.beginTransmission(MPU_ADDR);
  Wire.write(0x43);
  Wire.endTransmission();
  Wire.requestFrom(MPU_ADDR, 6);
  for(int i = 0 ; i < 3 ; ++i) {
    gyro[i] = Wire.read() << 8 | Wire.read();
    Serial.print(i);
    Serial.print(" = ");
    Serial.print(gyro[i]);
  }
  Serial.println("");
}

As you can see, in the function print_gyro(), i'm reading starting at the register 0x43. It's supposed to be the first register for the gyroscope x axis. But i'm getting the accelerometer data (the value update only when I move the MPU6050).

Then, I tried read from the register 0x3b (where it's supposed to be the accelerometer data) and now im getting values updating from the angle of the MPU6050.

Can someone tell me why ? Am I doing something wrong ? Does my MPU6050 registers crazy ? Am I crazy ??

Thanks for your help !

It is a MEMS sensor. The accelerometer measures the earth gravity when not moving. When it is in motion, it measures acceleration but it is very sensitive for vibrations.
The gyro measures the change in rotation. It does not measure the angle of the axis according to a steady mass, as would be expected with a mechanical gyro. The sensor data is still called "gyro", because it has something to do with rotation :wink:

Register 0x43 is indeed the first gyro register, the next 6 bytes are the axis with MSB first. You are reading them correct.

Everything is okay, what you see is how it behaves.

The MEMS sensors become useful with sensor fusion, when for example the accelerometer and the gyro and a magnetometer are combined. For example with the MPU-9250 and the AHRS filter.

Okay I understand ! Thanks !