I want accelerometer data from bmi270 sensor which is onboard the arduino ble sense rev2. But the values are in 1000s when kept horizontally on my desk. It should be around 1.00 on z axis and nearly 0 on x and y axis. Pls help. At times the readings cross 20,000. Pls note that the acceleration values do change linearly most of the time upon moving the board.
I used example code of Arduino__BMI270_BMM150.h library as below:
#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);
}
}
It looks to me like the library does no scaling at all, so you are seeing the raw values.
If that is the case, it is easy enough to scale them yourself. The acceleration along any vertical axis can be taken as 1g when the sensor is held still, so that defines the scale factor for that axis.
You will need to divide the values by 8192, because the accelerometer sensitivity for this sensor defaults to -/+ 4g of range (S4g in the table) for this board. Your values will likely saturate, depending on how hard you move, to -/+ 32768 units in your serial monitor.
Check out the Interrupts_subclassing example code which opens up more of the sensor's parameters for the user to tweak.
Thanks for your help. I figured that out earlier. For the gyroscope, the values need to be divided by 16.384. I also informed the guy who wrote this library and now he has added scaling in the library so we need not divide by these values anymore