Failed to initialize IMU!

I have already searched the forum for this topic but found no solution. I have just installed the IDE and can run successfully the blink example. There are no errors compiling the example SimpleAccelerometer (relevant snippet below) but running I receive the following message:

Started
Failed to initialize IMU!

My HW is a Nano 33 BLE Sense, Rev 2. There is no external wiring, just the USB. I have loaded the latest mBed: Arduino Mbed OS Nano Boards 4.0.2

The forums suggested added a library (marked in snippet) and using Mbed 1.3.1

The added library did not change behavior and Mbed 1.3.1 is not longer available.

Any help is appreciated!

---------------------- Code snippet ------------------------------------

#include "PluggableUSBHID.h"// Library that needs to be added
#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");
}

-------------- Compilation Messages ---------------------

Sketch uses 93536 bytes (9%) of program storage space. Maximum is 983040 bytes.
Global variables use 45936 bytes (17%) of dynamic memory, leaving 216208 bytes for local variables. Maximum is 262144 bytes.
Device       : nRF52840-QIAA
Version      : Arduino Bootloader (SAM-BA extended) 2.0 [Arduino:IKXYZ]
Address      : 0x0
Pages        : 256
Page Size    : 4096 bytes
Total Size   : 1024KB
Planes       : 1
Lock Regions : 0
Locked       : none
Security     : false
Erase flash

Done in 0.000 seconds
Write 93544 bytes to flash (23 pages)

[                              ] 0% (0/23 pages)
[=                             ] 4% (1/23 pages)
[==                            ] 8% (2/23 pages)
[===                           ] 13% (3/23 pages)
[=====                         ] 17% (4/23 pages)
[======                        ] 21% (5/23 pages)
[=======                       ] 26% (6/23 pages)
[=========                     ] 30% (7/23 pages)
[==========                    ] 34% (8/23 pages)
[===========                   ] 39% (9/23 pages)
[=============                 ] 43% (10/23 pages)
[==============                ] 47% (11/23 pages)
[===============               ] 52% (12/23 pages)
[================              ] 56% (13/23 pages)
[==================            ] 60% (14/23 pages)
[===================           ] 65% (15/23 pages)
[====================          ] 69% (16/23 pages)
[======================        ] 73% (17/23 pages)
[=======================       ] 78% (18/23 pages)
[========================      ] 82% (19/23 pages)
[==========================    ] 86% (20/23 pages)
[===========================   ] 91% (21/23 pages)
[============================  ] 95% (22/23 pages)
[==============================] 100% (23/23 pages)
Done in 3.857 seconds
1 Like

SOLVED
The required library is
#include "Arduino_BMI270_BMM150.h"
which can be downloaded with the library manager (search on the same name). The library manager also has examples which are accessed through the ... button

------------- Code now looks like -----------------

/* removed as not required
#include "PluggableUSBHID.h"// Library that needs to be added
#include <Arduino_LSM9DS1.h>
*/

#include "Arduino_BMI270_BMM150.h"

const float accelerationThreshold = 2.5; // threshold of significant in G's
const int numSamples = 119;

int samplesRead = numSamples;

void setup() {
  Serial.begin(9600);
  while (!Serial);

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

  // print the header
  Serial.println("aX,aY,aZ,gX,gY,gZ");
}
1 Like

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