I would like to read multiple reports from the BNO085. For example I want Linear Accel, Calibrated Gyroscope, and Calibrated Magnetometer
I am currently enabling the 3 reports:
Code: Select all
void setReports(){
if (! bno08x.enableReport(SH2_LINEAR_ACCELERATION, 4000)) {
Serial.println("Could not enable stabilized linear accel");
handle_error(CONFIGURATION_ERROR);
}
if (! bno08x.enableReport(SH2_GYROSCOPE_CALIBRATED, 4000)) {
Serial.println("Could not enable gyroscope");
handle_error(CONFIGURATION_ERROR);
}
if (! bno08x.enableReport(SH2_MAGNETIC_FIELD_CALIBRATED, 4000)) {
Serial.println("Could not enable magnetometer");
handle_error(CONFIGURATION_ERROR);
}
Serial.println("Set Reports");
}
Code: Select all
void read_sensor(){
if (bno08x.wasReset()) {
Serial.print("sensor was reset ");
setReports();
}
accel.isset = 0;
gyro.isset = 0;
mag.isset = 0;
while(!gyro.isset || !accel.isset || !mag.isset){
if (bno08x.getSensorEvent(&sensorValue)) {
switch(sensorValue.sensorId){
case SH2_GYROSCOPE_CALIBRATED:
gyro.isset = 1;
gyro.x = sensorValue.un.gyroscope.x;
gyro.y = sensorValue.un.gyroscope.y;
gyro.z = sensorValue.un.gyroscope.z;
break;
case SH2_LINEAR_ACCELERATION:
accel.isset = 1;
accel.x = sensorValue.un.linearAcceleration.x;
accel.y = sensorValue.un.linearAcceleration.y;
accel.z = sensorValue.un.linearAcceleration.z;
break;
case SH2_MAGNETIC_FIELD_CALIBRATED:
mag.isset = 1;
mag.x = sensorValue.un.magneticField.x;
mag.y = sensorValue.un.magneticField.y;
mag.z = sensorValue.un.magneticField.z;
break;
}
}
}
Serial.print(millis()); Serial.print("\t");
Serial.print(gyro.x); Serial.print("\t");
Serial.print(gyro.y); Serial.print("\t");
Serial.print(gyro.z); Serial.print("\t");
Serial.print(accel.x); Serial.print("\t");
Serial.print(accel.y); Serial.print("\t");
Serial.print(accel.z); Serial.print("\t");
Serial.print(mag.x); Serial.print("\t");
Serial.print(mag.y); Serial.print("\t");
Serial.println(mag.z);
}
Thats slow to the point that I have to assume there is a better way? Also... what's the deal with the BNO085 sometimes resetting so I need to be ready to recall that setReports and the bno08x.getSensorEvent seems to return false a fair number of times...
Oh, I am using I2c for the wiring, if that could be related?