# SparkFun Triple Axis Accelerometer Breakout - LIS331

**URL:** <https://community.sparkfun.com/t/sparkfun-triple-axis-accelerometer-breakout-lis331/36402>\
**Category:** IMU & Motion\
**Created:** [March 1, 2019, 6:21pm UTC](https://community.sparkfun.com/t/sparkfun-triple-axis-accelerometer-breakout-lis331/36402 "2019-03-01T18:21:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sixbacon](https://avatars.discourse-cdn.com/v4/letter/s/ecae2f/32.png) [@sixbacon](https://community.sparkfun.com/u/sixbacon)\
**Post date:** [March 1, 2019, 6:21pm UTC](https://community.sparkfun.com/t/sparkfun-triple-axis-accelerometer-breakout-lis331/36402/1 "2019-03-01T18:21:30Z")

</div>

Hi,

I am using this with an Arduino. I am using the library from [https://github.com/sparkfun/SparkFun\_LI … no\_Library](https://github.com/sparkfun/SparkFun_LIS331_Arduino_Library).

I can run the example given but when I try to change some setting in the registers, I am not successful.

I tried to change the full scale range from +/-6 g to +/-12 g and +/-24 g and the output was just wrong.

I could not find any reference to this library on your website, is it one you still recommend or support.

---

<div class="post-metadata">

**Author:** ![RipVW](https://avatars.discourse-cdn.com/v4/letter/r/9dc877/32.png) [@RipVW](https://community.sparkfun.com/u/RipVW)\
**Post date:** [March 7, 2019, 2:42am UTC](https://community.sparkfun.com/t/sparkfun-triple-axis-accelerometer-breakout-lis331/36402/2 "2019-03-07T02:42:33Z")

</div>

I had a similar problem so I ditched the library, got out the data sheet, and learned how to read/write the registers. Here is a quick sample on setting the range and reading the register to make sure it contains what you wish. Have spent many hours working with this unit - will try to help if I can.

```auto
 // Write to CTRL_REG4 register located at 0x23 to set Full Scale and some defaults
  // 1xxxxxxx Set most significant bit to one to avoid updating data registers between reading the MSB and LSB of data
  // x0xxxxxx Bit for selecting big or little endian - default is 0
  // xx00xxxx Sets full scale to low range
  // xx01xxxx Sets full scale to mid range
  // xx11xxxx Sets full scale to high range
  // xxxx0000 Default values
   Wire.beginTransmission(HH); // Talk to the 331HH
   Wire.write(0x23); //Writes the address of the register
   // Use only one of the following three statements - this assumes most signifcant bit is 1 and lower four bits are 0
    Wire.write(0x80); //Set Range to LOW 
    //Wire.write(0x90); //Set Range to MED
    //Wire.write(0xB0); //Set Range to HIGH 
   Wire.endTransmission(false); // false causes a restart to be sent
   
 // Read CTRL_REG4 register
   Wire.beginTransmission(HH); // Talk to the 331HH
   Wire.write(0x23); //Writes the address of the register   
   Wire.endTransmission(false); // false causes a restart to be sent
   Wire.requestFrom(HH, 1); // Request 1 byte
   if (Wire.available() > 0){
     Serial.print("CTRL_REG4: ");
     Serial.println(Wire.read(), HEX); // Print the contents of the register
   }
   else
   {
      Serial.println("No data received");
   } // End of if

```
