Display IMU data with LSM9DS1

arduino nano 33 ble sense imu LSM9DS1

Pre-requisites

Display IMU data with Arduino board Nano 33 BLE Sense with IMU LSM9DS1.

Install the dependancy:

arduino-cli lib install Arduino_LSM9DS1

Code

Download code
#include <Arduino_LSM9DS1.h>

void setup() {
  Serial.begin(9600);
  while (!Serial) {}
  Serial.println("Started");

  if (!IMU.begin()) {
    Serial.println("Failed to initialize IMU!");
    while (1) {}
  }

  Serial.print("Accelerometer sample rate = ");
  Serial.print(IMU.accelerationSampleRate());
  Serial.println(" Hz");
  Serial.println();
  Serial.println("Acceleration in G's");
  Serial.println("X\tY\tZ");
}

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

  if (IMU.accelerationAvailable()) {
    IMU.readAcceleration(x, y, z);

    Serial.print(x);
    Serial.print('\t');
    Serial.print(y);
    Serial.print('\t');
    Serial.println(z);
  }
}

Serial console

Serial output from the firmware.

Display IMU data with LSM9DS1 serial console

References