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.
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.
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.
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.)