Go Down

Topic: How to use self test registers in MPU 6050 registers 13 to 16 (Read 950 times) previous topic - next topic

Bunny9971

Code: [Select]


#include <Wire.h>

const int MPU = 0x68;
void setup() {
  Serial.begin(19200);
  Wire.begin();   
 /*   Wire.beginTransmission(MPU);       // Start communication with MPU6050 // MPU=0x68
  Wire.write(0x6B);                  // Talk to the register 6B
  Wire.write(0x00);                  // Make reset - place a 0 into the 6B register
  Wire.endTransmission(true); */
  Wire.beginTransmission(MPU);     
  Wire.write(0x6C);                  // Talking to Power_management_2 register
  Wire.write(0xC0);                 
  Wire.endTransmission(true);
 
   Wire.beginTransmission(MPU);     
  Wire.write(0x6B);                  // Talking to Power_management_1 register
  Wire.write(0xA8);                 
  Wire.endTransmission(true);

  Wire.beginTransmission(MPU);     
  Wire.write(0x1C);                  // Talking to Accelerometer configuration register
  Wire.write(0xF0);                 
  Wire.endTransmission(true);       
             
     
  delay(20);

}

void loop()
{
  Wire.beginTransmission(MPU);
  Wire.write(0x0D);              // Reading Self_test_x register
  Wire.endTransmission();
  Wire.requestFrom(MPU,1);     
  unsigned char data = Wire.read();
  Serial.println(data,HEX);
  delay(500);
}

Go Up