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
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);
}
}
Could you please explain what you mean by a bus contention?
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?
There is no hardware connected to the board, only the USB cable to my computer. How would I troubleshoot an i2c error?
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);
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.