Adafruit_LIS3DH
Adafruit_LIS3DH copied to clipboard
Library prevents usage of 1.25kHz Normal Power Mode
-
Arduino board: Adafruit Feather M0 BLE
-
Arduino IDE version (found in Arduino -> About Arduino menu): 1.8.10
-
List the steps to reproduce the problem below (if possible attach a sketch or copy the sketch code in too):
According to Table 26 in the LIS3DH datasheet, there is a 1.25 kHz sample rate available using Normal Power mode. The settings for ODR0
- ODR3
are identical to those for 5kHz low-power mode, which is an optional sample rate provided by this library. However, low-power mode sacrifices resolution according to section 3.2.1 of the datasheet.
LIS3DH provides two different operating modes respectively reported as normal mode and low power mode. While normal mode guarantees high resolution, low power mode reduces further the current consumption.
I was able to work around this by making writeRegister8
a public method so the necessary settings could be changed. Here's my code to set configure the sensor:
lis.setRange(LIS3DH_RANGE_8_G);
lis.setDataRate(LIS3DH_DATARATE_LOWPOWER_5KHZ);
// Disable LPen bit (for Normal power mode)
lis.writeRegister8(LIS3DH_REG_CTRL1, 0b10010111);
// Enable HR bit (for Normal power mode)
lis.writeRegister8(LIS3DH_REG_CTRL4, 0b10100000);
Since this library does not provide any other way to access the low-power or high-res settings, this was the simplest approach.