https://drive.google.com/file/d/11q5pZq ... sp=sharing
When I first got my sensor about a year ago, it was working well and I was using functions from the "rawdata" example. My serial monitor showed a calibration status of 3 for the gyro, accelerometers, and magnetometers and was showing the orientation data changing according to how I moved the sensor. After a while, I put the sensor on a custom pcb and now it seems like it is faulty. I believe that it could be because I didn't correctly put the sensor into NDOF mode but I am not so sure.
Does anyone know what could be the reason for the skewed values? I have tried looking everywhere for a problem similar to mine but haven't found any luck. I am also a high school student teaching myself how to code and use these sensors so things like data registers and addresses and how to use them are a completely new area of information for me so I apologize for any inconveniences or misunderstandings. I am willing to learn as much as I can. Below I have posted my code.
Please disregard any of the other devices such as the BMP085 and the Ebyte sensor. I have those working. My code for the BNO055 is at around lines 20, 52, 64, and 130.
I apologize again for any inconveniences and want to thank anyone that is willing to help.
Code: Select all
#include <Arduino.h>
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_I2CDevice.h>
#include <Adafruit_I2CRegister.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BMP085.h>
#include <Adafruit_BNO055.h>
#include <utility/imumaths.h>
#include <Servo.h>
#include <SoftwareSerial.h>
#include "EBYTE.h"
int buzzer = 14;
int red = 35;
int green = 36;
int blue = 37;
Adafruit_BMP085 bmp180;
Adafruit_BNO055 bno = Adafruit_BNO055 ();
void led_off(){
digitalWrite(red, HIGH);
digitalWrite(green, HIGH);
digitalWrite(blue, HIGH);
}
void setup() {
//Startup sound//
pinMode (buzzer, OUTPUT);
tone(buzzer, 440);
delay(100);
tone(buzzer, 659);
delay(100);
tone(buzzer, 880);
delay(100);
noTone(buzzer);
//LED startup//
pinMode(red, OUTPUT);
pinMode(green, OUTPUT);
pinMode(blue, OUTPUT);
digitalWrite(red, LOW);
digitalWrite(blue, LOW);
digitalWrite(green, HIGH);
delay(3000);
//Altimeter, Gyro, Radio calibration//
Serial.println("");
Serial.println("Calibrating altimeter...");
bmp180.begin();
Serial.println("Calibrating gyroscopes...");
bno.begin(bno.OPERATION_MODE_NDOF);
bno.setExtCrystalUse(true);
Serial.println("Starting radio...");
delay(3000);
Serial.begin(115200);
if (!bmp180.begin()){
Serial.print("BMP180 not working");
digitalWrite(red, LOW);
}
if (!bno.begin()){
Serial.print("BNO055 not working");
digitalWrite(red, LOW);
}
else{
led_off();
Serial.print("Altimeter and gyroscpoes are ready");
Serial.println();
Serial.println();
tone(buzzer, 2093);
delay(50);
noTone(buzzer);
delay(50);
tone(buzzer, 2093);
delay(50);
noTone(buzzer);
delay(50);
tone(buzzer, 2093);
delay(50);
noTone(buzzer);
delay(50);
}
}
void loop() {
//Set time
int time = millis() / 1000;
Serial.print("Time: ");
Serial.print(time);
Serial.print(" seconds ");
Serial.print("\t");
//Altitude
float initial_altitude;
float ground;
float altitude;
initial_altitude = bmp180.readAltitude();
ground = initial_altitude - initial_altitude;
altitude = ground;
float read = bmp180.readAltitude();
altitude = read - initial_altitude;
Serial.print("Altitude: ");
Serial.print(abs(altitude));
Serial.print(" meters ");
Serial.print("\t");
//Velocity//
float velocity = (abs(altitude / time));
Serial.print("Velocity: ");
Serial.print(velocity);
Serial.print(" m/s ");
Serial.print("\t");
//Acceleration//
float initial_velocity = velocity;
float final_velocity = initial_velocity;
float acceleration = (final_velocity - initial_velocity) / (time);
Serial.print("Acceleration: ");
Serial.print(acceleration);
Serial.print(" m/s^2");
Serial.print("\t");
//Orientation//
imu::Vector<3> orientation = bno.getVector(Adafruit_BNO055::VECTOR_GYROSCOPE);
Serial.print("X: ");
Serial.print(orientation.x());
Serial.print(" degrees ");
Serial.println("\t");
}