Hey, here is the code change, I also done that but the sensor doesn´t receive any accelaration stronger than 4g
int LSM6DS3Class::begin()
{
if (_spi != NULL) {
pinMode(_csPin, OUTPUT);
digitalWrite(_csPin, HIGH);
_spi->begin();
} else {
_wire->begin();
}
if (!(readRegister(LSM6DS3_WHO_AM_I_REG) == 0x6C || readRegister(LSM6DS3_WHO_AM_I_REG) == 0x69)) {
end();
return 0;
}
//set the gyroscope control register to work at 104 Hz, 2000 dps and in bypass mode
writeRegister(LSM6DS3_CTRL2_G, 0x4C);
// Set the Accelerometer control register to work at 104 Hz, 4 g,and in bypass mode and enable ODR/4
// low pass filter (check figure9 of LSM6DS3's datasheet)
writeRegister(LSM6DS3_CTRL1_XL, 0x4E);
// set gyroscope power mode to high performance and bandwidth to 16 MHz
writeRegister(LSM6DS3_CTRL7_G, 0x00);
// Set the ODR config register to ODR/4
writeRegister(LSM6DS3_CTRL8_XL, 0x09);
return 1;
}
I also created another function to change the accelaration range register value, I don´t know if that is going to affect the change of range for good.
int LSM6DS3Class::setAccelerationRange(int range){
uint8_t value;
switch (range)
{
case 2:
value = 0x00;
break;
case 4:
value = 0x10;
break;
case 8:
value = 0x11;
break;
case 16:
value = 0x01;
break;
default:
break;
}
uint8_t regValue = readRegister(LSM6DS3_CTRL1_XL);
regValue &= ~(0x0C);
regValue |= (value << 2);
writeRegister(LSM6DS3_CTRL1_XL, regValue);
}