I am using the bno055 to register some data. Suddenly, during the records, without a systematic time, the bno055 stops varying its output. If I reset the controller, the bno055 seems to work. I tried to reset the sensor directly inside the loop to avoid the controller's reset, but nothing happened. I did not find so much info about the reset of bno055. Can someone give me some tips to reach the solution?
Here's my code:
Code: Select all
/*** BUFFER******/
#include <SDRAM.h>
SDRAMClass mySDRAM;
float *dataA;
/**** BNO055 ****/
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BNO055.h>
#include <utility/imumaths.h>
Adafruit_BNO055 bno(-1, BNO055_ADDRESS_A, &Wire1);
/***Calculus****/
float q0A, q1A, q2A, q3A, gxA, gyA, gzA, normA, angle, accA, vxA, vyA, vzA, rollA, pitchA, yawA, axA, ayA, azA, gyxA, gyyA, gyzA;
float radtodeg = 57296 / 1000;
int j=0;
void setup() {
Wire1.begin();
Wire1.setClock(400000); //4Khz
while (!_UART_USB_);
/**** BNO055 ****/
if (!bno.begin()) {
_UART_USB_.print("Ooops, BNO055 Coscia not detected");
while (1);
}
bno.setExtCrystalUse(true);
dataA = (float*)SDRAM.malloc(0.5 * 512 * 512);
}
void loop() {
imu::Quaternion quatA = bno.getQuat();
q0A = quatA.w(); q1A = quatA.x(); q2A = quatA.y(); q3A = quatA.z();
gxA = q1A * q3A - q0A * q2A; gyA = q0A * q1A + q2A * q3A; gzA = q0A * q0A + q3A * q3A - 0.5f;
normA = sqrt(gxA * gxA + gyA * gyA + gzA * gzA); normA = 1.0 / normA;
gxA *= normA; gyA *= normA; gzA *= normA;
angle = acos(gxA); angle = angle * radtodeg;
dataA1[j] = angle;
if (angle==dataA[j-1] && angle==dataA[j-2]){
/*******RESET******/
bno.begin();
delay(1000);
}
j++;
}