Hi! I'm trying to do the "getting started with Machine Learning Arduino tutorial" and I keep finding the error "Failed to innitialize IMU" in the serial monitor. I know I have all of the libraries necissary and there is no additional wiring connected. Just confused as to why this is happening, any help would be great!
Forget for a moment the "getting started with Machine Learning Arduino tutorial."
Can you run a basic library test sketch from Arduino_LSM9DS1.h?
no I can't. it has the same error message as before. It reads "Started" then immediately after reads "Failed to innitialize IMU". I just got a new board in the mail and tried it on that one today, have the same error messages. I just got a new cable for the connection that should be fine. Attached are some screenshots of my IDE with the specs for more info, along with the example that I'm trying to run which is the simple accelerometer test in the library example section. I really dont know whats going on and its kindof driving me crazy at this point. thoughts?
#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);
}
}
I can't confirm your issue, and the library example sketch compiles and runs for me in the 2.1.0 IDE with 1.1.1 version of Arduino_LSM9DS1.h.
I am in a windows environment.
In the IDE under File>Preferences can you please enable the show verbose output on compile and post what you see. The code needs to be using the version of the Wire library bundled with the mbed nano core used by the Nano33BLE.
I don't know why there would be an issue, but it is the only thing I can think of for now.
What do you see with this scanner program which should find two devices. The LSM9DS1 has two i2c addresses which are on the Wire1 bus. One address is for the magnetometer,
#define LSM9DS1_ADDRESS 0x6b
#define LSM9DS1_ADDRESS_M 0x1e
Found address: 30 (0x1E)
Found address: 107 (0x6B)
Done.
Found 2 device(s).
// I2C Scanner
// Written by Nick Gammon
// Date: 20th April 2011
#include <Wire.h>
void setup() {
Serial.begin (115200);
// Leonardo: wait for serial port to connect
while (!Serial)
{
}
delay(2000);
Serial.println ();
Serial.println ("I2C scanner. Scanning ...");
Wire1.begin();
}
void loop() {
byte count = 0;
for (byte i = 8; i < 120; i++)
{
Wire1.beginTransmission (i);
if (Wire1.endTransmission () == 0)
{
Serial.print ("Found address: ");
Serial.print (i, DEC);
Serial.print (" (0x");
Serial.print (i, HEX);
Serial.println (")");
count++;
delay (1); // maybe unneeded?
} // end of good response
} // end of for loop
Serial.println ("Done.");
Serial.print ("Found ");
Serial.print (count, DEC);
Serial.println (" device(s).");
delay(5000);
}
EDIT: I ran this test on a Nano 33 BLE. The Sense version may have some additional devices on the i2c bus for some additional sensors.
I believe I found a solution. The Nano BLE Sense no longer uses the LSM9DS1 library, and instead uses the Arduino_BMI270_BMM150 library for the sensor that controls gyro, acceleration, and the compass. So I installed that new library and ran it with the same code and it worked perfectly. Don't know why the old library wasn't working, but now its working fine. Thanks for your help!
That's because its a Nano 33 BLE Sense Rev2 which has changed the IMU.
Sorry for the late reply, I noticed this a litte bit ago and corrected to the right library. Thank you for bringing this to light ![]()
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.


