No readings from IMU

Hello everyone,

I am attempting to access the IMU data from the Nano 33 BLE REV2 (ABX00071). I know it uses two IMUs, BMI270 and BMM150, and I am using the example sketch for the corresponding library.

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

This is the output from the serial monitor:

Started
Accelerometer sample rate = 0.39 Hz

Acceleration in G's
X	Y	Z

After a few minutes, the only reading seen is 0.00 0.00 0.00

Please advise :slight_smile:

Thank you!

  if (!IMU.begin()) {
    Serial.println("Failed to initialize IMU!");
    while (1);
  }
// Try adding this
  IMU.setContinuousMode();

Thank you for the advice!

I added that line, but I am afraid this is the output after a few minutes:

Started
Accelerometer sample rate = 0.39 Hz

Acceleration in G's
X	Y	Z
0.00	0.00	0.00

I have tried this with two boards of the same model and observed the same results. Additionally, a sample rate of 0.39Hz seems low no?

You must have some kind of bus contention. Here is the function you called that returned 0.39. It is supposed to return 119.0.

float LSM9DS1Class::accelerationSampleRate()
{
  return 119.0F;
}

You have not included the library.

#include "Arduino_BMI270_BMM150.h"

This is the library example for Simple Accellerometer

/*
  Arduino BMI270 - Simple Accelerometer

  This example reads the acceleration values from the BMI270
  sensor and continuously prints them to the Serial Monitor
  or Serial Plotter.

  The circuit:
  - Arduino Nano 33 BLE Sense Rev2

  created 10 Jul 2019
  by Riccardo Rizzo

  This example code is in the public domain.
*/

#include "Arduino_BMI270_BMM150.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);
  }
}

In addition to cattledog, the IMU uses i2c, which is connected to pins A4 and A5. You don't have any hardware connected there, do you?
Just checking.

I think the imu is connected internally on the board with Wire1on SDA1/SCL1 which is not routed to A4/A5.

Thank you both!

  1. Could you please explain what you mean by a bus contention?

  2. I have included the library in the script, I mistakenly did not include that when I copied my code here. The code I am uploading to the board is identical to the code provided. Do you have any other suggestions?

  3. There is no hardware connected to the board, only the USB cable to my computer. How would I troubleshoot an i2c error?

If you want to experiment, you can run the i2c_scanner sketch on Wire1.
Just a thought...

Thank you for the suggestion!

I found two I2C devices, one at 0x10 and one at 0x68. I presume these are the BMI270 and BMM150. From page 7 of the datasheet, it appears that these are the only I2C devices on board, so I think this is a fair judgement.

Is there anything else I could try? Is it possible I have received two dud boards?

0x68 is the BMI270.
0x10 is the BMM150
Don't know what to tell you.

Edit: Browsing through the library, I think the library is attempting to use Wire instead of Wire1. This is from /src/BoschSensorClass.h:
BoschSensorClass(TwoWire& wire = Wire);

One additional point - I modified the default IMU sketch to spit out the IMU sample rate - I see 99.84, which is expected in the documentation.

I'm going to try a couple of different nanos with a different IMU. Thank you for your help so far!

Just saw your most recent reply - I've now made that change and did not observe a difference in the output

No. See these lines 503-507 at the end of BMI270.cpp

#ifdef TARGET_ARDUINO_NANO33BLE
BoschSensorClass IMU_BMI270_BMM150(Wire1);
#else
BoschSensorClass IMU_BMI270_BMM150(Wire);
#endif

I do not the think the library is broken. There are no issues reported on github about the wrong bus being used. I have worked on other threads with people using that library on a Nano33 Ble rev2 and they are getting data from the imu.