Editing Arduino_LSM9DS1 to use external IMU

I am trying to adjust the Arduino_LSM9DS1 library to use an external LSM9DS1 connected over I2C, so that i can use the FIFO functionality of the library, which I have not been able to find in any of the other LSM9DS1 libraries.

Board: Arduino Nano 33 BLE
External IMU: Tinycircuite: 9-Axis Sensor Wireling

I have connected the external IMU and have found that its I2C addresse is different than the internal one, ie it is 0x6a for the accelerometer rather than 0x6b, which is the address of the built in IMU, and 0x1c for the magnetometer instead of 0x1e.

I also check the Who am i adress, and it is 0x0f, which is the same as the built in sensor.

I have gotten the external IMU to work with other libraries, so i know that it is live and readable.

I then tried replacing the two adresses in the arduino library, but this seems to break somewhere, because any code i now upload with the adjusted library, simply does nothing. No prints, no actions, nothing.

The definition section which i changed in the Arduino_LSM9DS1 library is the following:

#include "LSM9DS1.h"

#define LSM9DS1_ADDRESS            0x6a //this is the new accelerometer address

#define LSM9DS1_WHO_AM_I           0x0f //this address is the same for both IMUs
#define LSM9DS1_CTRL_REG1_G        0x10
#define LSM9DS1_STATUS_REG         0x17
#define LSM9DS1_OUT_X_G            0x18
#define LSM9DS1_CTRL_REG6_XL       0x20
#define LSM9DS1_CTRL_REG8          0x22
#define LSM9DS1_OUT_X_XL           0x28

// magnetometer
#define LSM9DS1_ADDRESS_M          0x1c // this is the new magnetometer address

#define LSM9DS1_CTRL_REG1_M        0x20
#define LSM9DS1_CTRL_REG2_M        0x21
#define LSM9DS1_CTRL_REG3_M        0x22
#define LSM9DS1_STATUS_REG_M       0x27
#define LSM9DS1_OUT_X_L_M          0x28

I cannot find any part of the library that does not use the adjusted addresses, and dont know how to check where in the library the code is failing.

To test the adjusted library I am using the libraries own example script:

#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);
  }
}

Any help would be much appreciated

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