Arduino IMU Capping at 4.0 Acceleration

Hi! I recently brought an Arduino Nano 33 BLE Sense and I’m trying to log the accelerometer data using the IMU feature. However, when I print the accelerations into the console, they are capped at an absolute value of 4.00 for each axis. Does anyone know how to fix this? I have put the code below:

//This is the test realm. New features and nonsense is tested here before integration into the main code.

#include <Arduino_LSM9DS1.h>
#include <Arduino_LPS22HB.h>

float xData[3000];
float yData[3000];
float zData[3000];

int timer = 0;

void setup()
{
  if (!IMU.begin()) {
    Serial.println("Failed to initialize IMU!");
    exit(1);
  }
  
  if (!BARO.begin()) {
    Serial.println("Failed to initialize BARO!");
    exit(2);
  }
}

void loop()
{
  float x, y, z = 0.0;

  if (IMU.accelerationAvailable())
  {
    IMU.readAcceleration(x, y, z);
    
    xData[timer] = x;
    yData[timer] = y;
    zData[timer] = z;
    
    Serial.print("Acceleration at time ");
    Serial.print(millis());
    Serial.print("ms: "); 
    Serial.print(x);
    Serial.print(", ");
    Serial.print(y);
    Serial.print(", ");
    Serial.println(z);
  }
  
  float pressure = BARO.readPressure();

  Serial.print("Pressure at time ");
  Serial.print(millis());
  Serial.print("ms: "); 
  Serial.print(pressure);
  Serial.println(" kPa");
  Serial.println();

  timer += 1;
  delay(100);
}

Some of the output data is here:

11:02:49.843 -> Acceleration at time 60489ms: -0.41, -0.27, 0.13
11:02:49.843 -> Pressure at time 60496ms: 99.76 kPa
11:02:49.843 -> 
11:02:49.943 -> Acceleration at time 60599ms: -4.00, 4.00, -4.00
11:02:49.943 -> Pressure at time 60606ms: 99.77 kPa
11:02:49.977 -> 
11:02:50.080 -> Acceleration at time 60710ms: -0.32, 0.73, -0.37
11:02:50.080 -> Pressure at time 60717ms: 99.78 kPa

As you can see, at timestamp 11:02:49.943, all of the data is capped at an absolute value of 4.00. This experiment was repeated multiple times and the same result occurred. Is there a way to change/fix this? Thanks!

Thank you!

Set the LSM9DS1 to one of the higher acceleration ranges. See the library docs for how to do that, if implemented.

From Arduino - ArduinoLSM9DS1

The library takes care of the sensor initialisation and sets its values as follows:

Accelerometer range is set at [-4,+4]g -/+0.122 mg

Thank you! Unfortunately, I'm not sure how to set the accelerometer to a different range and the API isn't too clear on how to do that either. How would I implement this into the code I'm using? Thanks!

You could either use the Wire library to modify the appropriate settings register (CTRL_REG6_XL controls the accelerometer scale), or use a more complete device library, like the Sparkfun LSM9DS1 library.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.