04-29-2020 04:28 PM
Hi everybody,
I have a BMI160 sensor, which is connected to my Adafruit Feather M0 Bluefruit LE development board to measure the acceleration and orientation. I have found a code online for the development board (through Arduino IDE) and I uploaded the code to my board. I successfully receive sensordata via Bluetooth Low Energy at my computer, however these data are not meaningful. My question is how do I "convert" these raw data into meaningful data (i.e. in m/s² and °/s) ?
//output
//No matter how I move the sensor, the first zeros remain
0000002452552255248620
0000002522552015248620
000000702245239620
0000002539770124620
0000002438555667500
00000022842354974400
0000002152422464345380
000000212026218620
Here is a part of the code for the development board:
void loop(void) {
byte data[12];
if(millis()-lastUpdate >=1000)
{
lastUpdate = millis();
for (int i = 0; i < 12; i++)
{
// Read 12 bytes of data
// xGyr lsb, xGyr msb, yGyr lsb, yGyr msb, zGyr lsb, zGyr msb
// xAccl lsb, xAccl msb, yAccl lsb, yAccl msb, zAccl lsb, zAccl msb
data[i]=readBMI(12+i);
ble.print(data[i]); //send value to bluefruit uart
Serial.print(data[i], HEX);
Serial.print(" ");
Serial.print(i);
Serial.print(" ");
if(i==11){
ble.print(byte(0x00));
}
}
ble.println(); //print newline so app knows to plot the values
Serial.println();
}
}
//-----------------------------------------------------------
byte readBMI(int reg)
{
byte data = 0x00;
// Start I2C Transmission
Wire.beginTransmission(AddrBMI160);
// Select data register
Wire.write(reg);
// Stop I2C Transmission
Wire.endTransmission();
// Request 1 byte of data
Wire.requestFrom(AddrBMI160, 1);
// Read 12 bytes of data
// xGyr lsb, xGyr msb, yGyr lsb, yGyr msb, zGyr lsb, zGyr msb
// xAccl lsb, xAccl msb, yAccl lsb, yAccl msb, zAccl lsb, zAccl msb
if (Wire.available() == 1)
{
data = Wire.read();
}
return data;
}
04-29-2020 11:51 PM - edited 04-29-2020 11:57 PM