Accelerometer Keeps on Giving Me 0s

Hello!
I have encountered a problem when using the Arduino Nano 33 BLE Rev 2 (a mouthful, I know) to use the built in accelerometer. I am using the sample code for the Arduino_BMI270_BMM150 library, (below) but when I test it, I keep on getting 0 in the x, y, and z columns. Help would GREATLY be appreciated, since I don't want to get another board.

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

I moved your topic to an appropriate forum category @bassoon30

In the future, please take some time to pick the forum category that best suits the subject of your topic. There is an "About the _____ category" topic at the top of each category that explains its purpose.

This is an important part of responsible forum usage, as explained in the "How to get the best out of this forum" guide. The guide contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

Note - A BLE "Rev 1" has a different IMU, an LSM9DS1.

If you definitely have a Rev2
and you see
Started
in Serial Monitor
and then three columns (X, Y, Z) with nothing but 0.00
then you can conclude that it's a bad unit.

Are you sure? Since, I have been seeing the gyroscope data with this same Nano.

I have run the Example sketch on my Rev2 successfully.

Try reading out and printing both sets of gyro and accelerometer data values in the same program. If you continue to have trouble, post the code and example output.

If the accelerometer is held still, it should read 1 g (or the equivalent in other units) along a vertical axis.

will do...

Sorry it took me a minute to combine and run the code.

Ummm... yeah. Even though my code was correct, nothing happened. The gyroscope data and accelerometer data took turns appearing. (Accelerometer first)

I'm really sorry for annoying you about this, but can you paste the sketch and which version of the library you used. Sorry again. (I guess I'm a little nervous about the sketch.)

I did the i2C scan to make sure the IMU is connected. It said yes Mr. runaway_pancake.

Why didn't you post the revised code, as requested?

The accelerometer data is not correct. If you turn the device, do the gyro readings change?

No.

Then either your code is wrong, or the IMU is not working. Good luck!

Oh. That's a problem. Thanks for your help though!

The secondary side of your board looks just like this then --

Yeah... I'll have to test this out a bit more. Thank you though Mr. Pancake!!

Sure would be nice if someone could answer a question. (I'm 0 for 2 here.)

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