How can we change the default setting of gyro and accelerometer sensitivity?

Hi..
The default is setting for accelerometer is +/-2G and for gyro is +/-250deg/sec. So what are the changes one should make in mpu6050.cpp and mpu6050.h to change default setting?

thanks in advanced.

MPU6050::MPU6050(PinName sda, PinName scl) : connection(sda, scl) {
    this->setSleepMode(false);
    
    //Initializations:
    currentGyroRange = 0;
    currentAcceleroRange=0;
}

I would think that if you change currentGyorRange and currentAcceloRange, in MPU6050.cpp, according to

#define MPU6050_ACCELERO_RANGE_2G   0
#define MPU6050_ACCELERO_RANGE_4G   1
#define MPU6050_ACCELERO_RANGE_8G   2
#define MPU6050_ACCELERO_RANGE_16G  3
 
#define MPU6050_GYRO_RANGE_250      0
#define MPU6050_GYRO_RANGE_500      1
#define MPU6050_GYRO_RANGE_1000     2
#define MPU6050_GYRO_RANGE_2000     3

That would change the default.

Since, i an new to arduino, it would be great if you just tell me where should i put the code that you have mentioned.

Here is my code:

#include "I2Cdev.h"
#include "MPU6050.h"
#include "Wire.h"
MPU6050 accelgyro;
int16_t ax, ay, az;
int16_t gx, gy, gz;
#define OUTPUT_READABLE_ACCELGYRO
#define LED_PIN 13
bool blinkState = false;
void setup() {
    
        Wire.begin();
    Serial.begin(38400);
    accelgyro.initialize();
    pinMode(LED_PIN, OUTPUT);
}

unsigned long timer;
void loop() {
    accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
     if((millis() - timer) > 8) // 100Hz
    {
      timer = millis();
      Serial.print(timer);Serial.print("\t");
      // int start=millis();Serial.print(start);Serial.print("\t");
        Serial.print(ax); Serial.print("\t");
        Serial.print(ay); Serial.print("\t");
        Serial.print(az); Serial.print("\t");
        Serial.print(gx); Serial.print("\t");
        Serial.print(gy); Serial.print("\t");
        Serial.println(gz);
    blinkState = !blinkState;
    digitalWrite(LED_PIN, blinkState);
}
}
void setup() {
    
    Wire.begin();
    Serial.begin(38400);
    accelgyro.initialize();

    setFullScaleGyroRange(MPU6050_GYRO_FS_250);  
    setFullScaleAccelRange(MPU6050_ACCEL_FS_2);  

    pinMode(LED_PIN, OUTPUT);
}
#define MPU6050_ACCEL_FS_2 0x00
#define MPU6050_ACCEL_FS_4 0x01
#define MPU6050_ACCEL_FS_8 0x02
#define MPU6050_ACCEL_FS_16 0x03

#define MPU6050_GYRO_FS_250 0x00
#define MPU6050_GYRO_FS_500 0x01
#define MPU6050_GYRO_FS_1000 0x02
#define MPU6050_GYRO_FS_2000 0x03

Hi...
Thank you so much for your reply. Now i think its working fine. Here is the code:

#include "I2Cdev.h"
#include "MPU6050.h"
#include "Wire.h"
MPU6050 accelgyro;
int16_t ax, ay, az;
int16_t gx, gy, gz;
#define OUTPUT_READABLE_ACCELGYRO
#define LED_PIN 13
#define MPU6050_ACCEL_FS_2 0x00
#define MPU6050_ACCEL_FS_4 0x01
#define MPU6050_ACCEL_FS_8 0x02
#define MPU6050_ACCEL_FS_16 0x03

#define MPU6050_GYRO_FS_250 0x00
#define MPU6050_GYRO_FS_500 0x01
#define MPU6050_GYRO_FS_1000 0x02
#define MPU6050_GYRO_FS_2000 0x03
bool blinkState = false;
void setup() {
    
        Wire.begin();
    Serial.begin(38400);
    accelgyro.initialize();
    int setFullScaleGyroRange(MPU6050_GYRO_FS_2000);  
    int setFullScaleAccelRange(MPU6050_ACCEL_FS_2);  
    pinMode(LED_PIN, OUTPUT);
}

unsigned long timer;
void loop() {
    accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
     if((millis() - timer) > 8) // 100Hz
    {
      timer = millis();
      Serial.print(timer);Serial.print("\t");
      // int start=millis();Serial.print(start);Serial.print("\t");
        Serial.print(ax); Serial.print("\t");
        Serial.print(ay); Serial.print("\t");
        Serial.print(az); Serial.print("\t");
        Serial.print(gx); Serial.print("\t");
        Serial.print(gy); Serial.print("\t");
        Serial.println(gz);
    blinkState = !blinkState;
    digitalWrite(LED_PIN, blinkState);
}
}

Just wanted to clarify that even though we change the full scale range, the values of sensor remains the same. The only change is now in sensitivity scaling factor. Right?

The accel will work like that because when you change the range you are changing the number of bits in the result, the scaling is automatically set for all ranges, I am not sure about the gyro. It has been a while since I used the gyro. Edit: Can you post a link to the MPU6050 datasheet (that you have) so that I know that we are talking about the same part(s).

Here is a link for datasheet.
http://www.invensense.com/mems/gyro/documents/PS-MPU-6000A-00v3.4.pdf

I want to change a gyro sensitivity from 250 to 2000 deg/sec.
I observed that the serial monitor output is remain the same. It varies from -32768 to 32768.
so for sensitivity of 250 deg/sec: scaling factor is 250/32768
and for sensitivity of 2000 deg/sec: scaling factor is 2000/32768

Right?

Right. I may have been wrong about the a acell gain. You probably have to set the scaling according to range. Check the data sheet.