Pololu Robotics & Electronics
My account Comments or questions? About Pololu Contact Ordering information Distributors

Changing Sensitivity of LSM303D accel/magnometer


Hi, I’m trying to determine how to changed the sensitivity of the LSM303D accelerometer. I have seen multiple different spec sheets that have stated that it is possible to switch from the 2g, 4g, 8g modes, but I can not seem to figure out how. I am under the impression that it is a simple registry write. However, I have been unable to find the right registry. I am using the LSM303 Arduino library so if someone could shed some light on this I would be incredibly grateful.


Hi Pi_Co, here you go. Just add to your code, don’t change any library stuff.
Also included is the Mag. If you change the Mag you need to re calibrate the IMU for each Gauss.
Have given Gyro as well, just uncomment/comment what you need.

void Accel_Init()
  switch (compass.getDeviceType())
    case LSM303::device_D:
      // compass.writeReg(LSM303::CTRL1, 55);//Accel 100hz, all axis enabled
    //  compass.writeReg(LSM303::CTRL2, 0);//Accel------------------2g= 
    compass.writeReg(LSM303::CTRL2, 0x18);//-----------------0x18= 8 g full scale: AFS = 011
   //  compass.writeReg(LSM303::CTRL2, 0x20);//------------------16g
  // compass.writeReg(LSM303::CTRL5, 8);//  12.5 hz ODR,low resolution, DEFAULT= 24 
  // compass.writeReg(LSM303::CTRL6, 0);// change default +-4 gauss to +-2 gauss.--------------------- NEED TO REDO MAG CAL. 2 gauss approx 8000 range,

void Gyro_Init()
//  gyro.writeReg(L3G::CTRL_REG4, 0x20); // Default--- 2000 dps full scale------ Also require to change sensitivty    70 for 2000dps
  gyro.writeReg(L3G::CTRL_REG4, 0); // 245 full scale in decimal--------Also require to change sensitivity   8.75 for 245 dps
  gyro.writeReg(L3G::CTRL_REG1, 0x0F); // normal power mode, all axes enabled, 100 Hz