MPU6050 Accel. Sensitivity

Hi,

I recently bought an MPU6050 and have got two separate codes working (courtesy of others), one outputs angles from the DMP, and the other raw data.

My problem is I do not know how to change the accelerometer sensitivity from 2g to 4g.

#include<Wire.h>
const int MPU_addr=0x68;  // I2C address of the MPU-6050
int16_t AcX,AcY,AcZ,Tmp,GyX,GyY,GyZ;

void setup(){
  Wire.begin();
  Wire.beginTransmission(MPU_addr);
  Wire.write(0x6B);  // PWR_MGMT_1 register
  Wire.write(0);     // set to zero (wakes up the MPU-6050)
  Wire.endTransmission(true);
  Serial.begin(9600);

  
}
void loop(){
  Wire.beginTransmission(MPU_addr);
  Wire.write(0x3B);  // starting with register 0x3B (ACCEL_XOUT_H)
  Wire.endTransmission(false);
  Wire.requestFrom(MPU_addr,14,true);  // request a total of 14 registers
  AcX=Wire.read()<<8|Wire.read();  // 0x3B (ACCEL_XOUT_H) & 0x3C (ACCEL_XOUT_L)     
  AcY=Wire.read()<<8|Wire.read();  // 0x3D (ACCEL_YOUT_H) & 0x3E (ACCEL_YOUT_L)
  AcZ=Wire.read()<<8|Wire.read();  // 0x3F (ACCEL_ZOUT_H) & 0x40 (ACCEL_ZOUT_L)
  Tmp=Wire.read()<<8|Wire.read();  // 0x41 (TEMP_OUT_H) & 0x42 (TEMP_OUT_L)
  GyX=Wire.read()<<8|Wire.read();  // 0x43 (GYRO_XOUT_H) & 0x44 (GYRO_XOUT_L)
  GyY=Wire.read()<<8|Wire.read();  // 0x45 (GYRO_YOUT_H) & 0x46 (GYRO_YOUT_L)
  GyZ=Wire.read()<<8|Wire.read();  // 0x47 (GYRO_ZOUT_H) & 0x48 (GYRO_ZOUT_L)
  Serial.print("AcX = "); Serial.print(AcX);
  Serial.print(" | AcY = "); Serial.print(AcY);
  Serial.print(" | AcZ = "); Serial.print(AcZ);
  Serial.print(" | Tmp = "); Serial.print(Tmp/340.00+36.53);  //equation for temperature in degrees C from datasheet
  Serial.print(" | GyX = "); Serial.print(GyX);
  Serial.print(" | GyY = "); Serial.print(GyY);
  Serial.print(" | GyZ = "); Serial.println(GyZ);
  delay(333);
}

AcX = -16 | AcY = -26 | AcZ = 16434 | Tmp = 26.84 | GyX = -1 | GyY = 1 | GyZ = 0

that is the output line from the serial monitor which I understand, 16434 equates to around 1g.

It is just the process of changing the values that I am unsure about. Do I edit the .h or .cpp files, unsure really.

Sorry if this is a really obvious question, and thank you to any one who can help a beginner out.

See Register 28.

Thanks, but I am still unsure of the actual process itself of issuing that change to the chip.. Any help?

I think the first document covers how to read and write registers.

The second document covers the register numbers and what each contains.

Read the register. Change the data you want to change. Write the changed data back to the register.

I'm fairly sure someone has done this before so a Google search that includes the field name might turn up code someone else wrote to do the same thing.

I love using the MPU6050 and have excellent success with it for several projects.
The MPU6050.h mpu6050.cpp have detailed list of registers and functions designed to set and use them. they also have several examples on how to use this class. I have both used the class and dissected pieces of code for specific projects.

They even have DMP processing of angles and an example on how to use it!!!

Thanks guys, I'll digest this all and give it a go, I'm not very proficient at coding (if you hadn't noticed) but I'm trying!

Hi Jaddion.
Did you figure this one out. ?