I have an app that is supposed to take gyro readings 500 times / second, so 500Hz.
With the Rev1 board using the LSM9 sensor that worked fine, I just had to insert a delayMicroseconds between each read.
I tried the same approach with the Rev2 board but is not working well. After inserting some millis() calls, I discovered that each call to readGyro is now taking about 7mS to return !
I'm using the "official" Arduino_BMI270_BMM150 library and configuring the gyro like: sens_cfg[1].type = BMI2_GYRO; sens_cfg[1].cfg.gyr.filter_perf = BMI2_PERF_OPT_MODE; sens_cfg[1].cfg.gyr.noise_perf = BMI2_GYR_RANGE_2000; sens_cfg[1].cfg.gyr.bwp = BMI2_GYR_OSR2_MODE; sens_cfg[1].cfg.gyr.odr = BMI2_GYR_ODR_1600HZ; sens_cfg[1].cfg.gyr.range = BMI2_GYR_RANGE_2000; sens_cfg[1].cfg.gyr.ois_range = BMI2_GYR_OIS_2000;
I'll give Sparkfun a try.
I don't think the Bosch sensor is the issue. Looking at the specs it seems more capable than the LSM9. However, it also look a lot harder to master.
I just tried one of the Sparkfun examples (see below), but it didn't work. It always reports that the BMI270 isn't found.
That's strange because I think on the Nano 33 BLE, the BMI is wired in the same way as in the Adafruit breakout boards (I2C with address 0x68).
What could be failing ?
#include <Wire.h>
#include "SparkFun_BMI270_Arduino_Library.h"
// Create a new sensor object
BMI270 imu;
// I2C address selection
uint8_t i2cAddress = BMI2_I2C_PRIM_ADDR; // 0x68
//uint8_t i2cAddress = BMI2_I2C_SEC_ADDR; // 0x69
void setup()
{
// Start serial
Serial.begin(115200);
Serial.println("BMI270 Example 1 - Basic Readings I2C");
// Initialize the I2C library
Wire.begin();
// Check if sensor is connected and initialize
// Address is optional (defaults to 0x68)
while(imu.beginI2C(i2cAddress) != BMI2_OK)
{
// Not connected, inform user
Serial.println("Error: BMI270 not connected, check wiring and I2C address!");
// Wait a bit to see if connection is established
delay(1000);
}
Serial.println("BMI270 connected!");
}
void loop()
{
// Get measurements from the sensor. This must be called before accessing
// the sensor data, otherwise it will never update
imu.getSensorData();
// Print acceleration data
Serial.print("Acceleration in g's");
Serial.print("\t");
Serial.print("X: ");
Serial.print(imu.data.accelX, 3);
Serial.print("\t");
Serial.print("Y: ");
Serial.print(imu.data.accelY, 3);
Serial.print("\t");
Serial.print("Z: ");
Serial.print(imu.data.accelZ, 3);
Serial.print("\t");
// Print rotation data
Serial.print("Rotation in deg/sec");
Serial.print("\t");
Serial.print("X: ");
Serial.print(imu.data.gyroX, 3);
Serial.print("\t");
Serial.print("Y: ");
Serial.print(imu.data.gyroY, 3);
Serial.print("\t");
Serial.print("Z: ");
Serial.println(imu.data.gyroZ, 3);
// Print 50x per second
delay(20);
}