I'm facing a problem that I've tried everything and it doesn't solve it. I just want to read the acceleration on the serial monitor and plotter for now, the code runs, works and is OK, I've already changed and tested the Arduino, sensor, breadboard... and it's OK. everything works normally but it simply repeats the initial line start 0, in other words, it's as if it didn't have a sensor, it simply doesn't read, it doesn't update. Sometimes it spikes and shows different values for a few seconds or right at the beginning, but it's very rare. I'm already hoping that the libraries are downloaded and working correctly, the port settings are correct, I've already soldered the sensor (tested it again, it works) and it's connected to +5v, so I'm suspecting that it might not work for this sensor, which is a cheaper version of the original (but with the same name: BNO055) or it could be a protocol error too, anyway I have no idea what it could be.
(Ignore the MPU in the image, I was using it to test)
Source code:
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BNO055.h>
#include <utility/imumaths.h>
#include <math.h>
#define BNO055_SAMPLERATE_DELAY_MS (100)
Adafruit_BNO055 myIMU = Adafruit_BNO055();
float thetaM;
float phiM;
float thetaFold = 0;
float thetaFnew;
float phiFold = 0;
float phiFnew;
void setup() {
Serial.begin(115200);
myIMU.begin();
delay(1000);
int8_t temp = myIMU.getTemp();
// Serial.printIn(temp);
myIMU.setExtCrystalUse(true);
}
void loop() {
uint8_t system, gyro, accel, mg = 0;
myIMU.getCalibration(&system, &gyro, &accel, &mg);
imu::Vector<3> acc = myIMU.getVector(Adafruit_BNO055::VECTOR_ACCELEROMETER);
thetaM = -atan2(acc.x() / 9.8, acc.z() /9.8) / 2/ 3.141592654 * 360;
phiM = atan2(acc.y() / 9.8, acc.z() / 9.8) / 2/ 3.141592654 * 360;
thetaFnew = .9 * thetaFold + .1 * thetaM;
phiFnew = .9 * phiFold + .1 * phiM;
Serial.print(acc.x() / 9.8);
Serial.print(",");
Serial.print(acc.y() / 9.8);
Serial.print(",");
Serial.print(acc.z() / 9.8);
Serial.print(",");
Serial.print(accel);
Serial.print(",");
Serial.print(gyro);
Serial.print(",");
Serial.print(mg);
Serial.print(",");
Serial.print(system);
Serial.print(",");
Serial.print(thetaM);
Serial.print(",");
Serial.print(phiM);
Serial.print(thetaFnew);
Serial.print(",");
Serial.println(phiFnew);
phiFold = phiFnew;
thetaFold = thetaFnew;
delay(BNO055_SAMPLERATE_DELAY_MS);
}