BNO055 not reading correct values

For other supported Arduino products from Adafruit: Shields, accessories, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
MrTanaka64
 
Posts: 4
Joined: Tue Jul 19, 2022 12:25 am

BNO055 not reading correct values

Post by MrTanaka64 »

Hello, I am currently working on a rocketry flight computer that uses the BNO055 with a Teensy 3.5. My main conflict is that the sensor isn't reading the gyroscopic values correctly. When I first turn it on, for around 2 seconds, I get a value of -0.06 and then a value of 0 no matter how I turn the sensor. Below is an image of the serial monitor reading -0.06 and then 0.

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");


}


User avatar
gammaburst
 
Posts: 1013
Joined: Thu Dec 31, 2015 12:06 pm

Re: BNO055 not reading correct values

Post by gammaburst »

Hi MrTanaka64,

When requesting troubleshooting assistance, I suggest:
- Include a small sketch that contains just enough code to demonstrate the problem.
- Include a simple photo that shows all your connections.

I stripped away your code unrelated to BNO055. I changed your "degrees" to "degrees/second" because that's what a gyroscope outputs:

Code: Select all

#include <Adafruit_BNO055.h>

Adafruit_BNO055 bno = Adafruit_BNO055 ();

void setup()
{
  Serial.begin(115200);

  if (!bno.begin())
    Serial.println("BNO055 not working");
  else
    Serial.println("Gyroscopes are ready");
}

void loop()
{
  imu::Vector<3> orientation = bno.getVector(Adafruit_BNO055::VECTOR_GYROSCOPE);
  Serial.print("X: ");
  Serial.print(orientation.x());
  Serial.println(" degrees/second");

  delay(10);
}
I ran it on a Teensy 3.5 (also an Arduino Uno), and it outputs good X gyroscope values as I gently tilt the sensor back and forth:

Code: Select all

Gyroscopes are ready
X: 13.31 degrees/second
X: 7.81 degrees/second
X: -3.50 degrees/second
X: -9.31 degrees/second
X: -3.94 degrees/second
X: 4.75 degrees/second
X: 5.38 degrees/second
X: -1.19 degrees/second
X: -7.44 degrees/second
X: -7.50 degrees/second
X: 0.63 degrees/second
X: 4.69 degrees/second
X: 3.19 degrees/second
X: 0.75 degrees/second
X: 0.38 degrees/second
X: 0.56 degrees/second
X: 3.50 degrees/second
Here's my breadboard. The extra SDA pullup resistor (around 2K to 3K ohms) is necessary for stable BNO055 operation:
BNO055 with Teensy 3.5 including extra SDA pullup resistor
BNO055 with Teensy 3.5 including extra SDA pullup resistor
IMG_2647a.jpg (237.88 KiB) Viewed 1324 times
I hope that helps you find your problem!

User avatar
MrTanaka64
 
Posts: 4
Joined: Tue Jul 19, 2022 12:25 am

Re: BNO055 not reading correct values

Post by MrTanaka64 »

Thank you for your help, but I still wasn't able to get the sensor working. I don't have any 2/3k ohm resistors on me so I used 2 1kohm resistors in series with the sda pin. I also changed the connection of Vin to go to the 3.3 volt pin rather than the Vin pin on the teensy and that didn't work either. Please let me know if the wiring in the picture is unclear.

https://drive.google.com/file/d/1cETtAK ... sp=sharing

User avatar
gammaburst
 
Posts: 1013
Joined: Thu Dec 31, 2015 12:06 pm

Re: BNO055 not reading correct values

Post by gammaburst »

Your breadboard wiring looks equivalent to mine.
Your two 1K resistors in series are fine.

I'm seeing a strong parallax effect in your photo. Does your Teensy have long pins? Its pin spacing appears to not match the breadboard hole spacing.

I don't know what's causing your malfunction. Did you try running my simplified code? Did you try rerunning the rawdata example as you've done in the past? Perhaps you need to update your Adafruit BNO055 library and Teensy support package to the latest versions, then try recompiling your code. But that's just a guess. Other folks may have more suggestions.

User avatar
MrTanaka64
 
Posts: 4
Joined: Tue Jul 19, 2022 12:25 am

Re: BNO055 not reading correct values

Post by MrTanaka64 »

I am using the same teensy 3.5 but I just inserted it into some female header connectors to make it easier to take on and off the breadboard. I also ran both the simplified code that you provided as well as the rawdata example. It if helps to know, I am using vscode with the platformio extension to code the instrument. Could that have an effect on the current status of the library? I will research into restarting/updating the teensy and updating the library.

Thank you for the continued help!

User avatar
gammaburst
 
Posts: 1013
Joined: Thu Dec 31, 2015 12:06 pm

Re: BNO055 not reading correct values

Post by gammaburst »

"I also ran both the simplified code that you provided as well as the rawdata example."
What were the results of those tests?

Your observation could be the clue: "I put the sensor on a custom pcb and now it seems like it is faulty." Perhaps damage occurred during the move. I would try returning to the point where things were working. That could mean buying replacement modules, or reinstalling previous versions of development tools.

Or try testing the BNO055 with a simple microcontroller such as an Arduino Uno, and using the common Arduino IDE environment.

Do you have two Teensy modules and two BNO055 modules? Or are you moving one set back and forth between your custom PCB and the breadboard?

I'm unfamiliar with vscode and platformio. I can't help with them, sorry.

User avatar
adafruit_support_carter
 
Posts: 29056
Joined: Tue Nov 29, 2016 2:45 pm

Re: BNO055 not reading correct values

Post by adafruit_support_carter »

The Adafruit BNO55 breakout includes the necessary pull up resistors. Should not need to add any additional external resistors.

Is the Teensy the only board available for testing? Do you have an UNO or something equivalent to try using the BNO055 per the guide:
https://learn.adafruit.com/adafruit-bno ... duino-code
as a way to check basic functionality?

User avatar
gammaburst
 
Posts: 1013
Joined: Thu Dec 31, 2015 12:06 pm

Re: BNO055 not reading correct values

Post by gammaburst »

Hi adafruit_support_carter,

That's incorrect about the pullup resistors. The BNO055 and BNO08x have an insidious bug in their I2C controller that creates an SDA-high to SCL-high setup time violation during some clock-stretching cycles. That puts the I2C bus on the verge of malfunction unless you take steps to improve the setup time. (Adafruit's products and tutorials don't take any such steps.) One easy workaround is to add an extra 2K or 3K pullup resistor to SDA so it rises significantly faster than SCL. That doesn't eliminate the timing violation, but it improves the timing sufficiently to avoid bus failures and instability in all the BNO projects that I've seen. The only proper solution that I can think of is for Bosch to fix their design.

One of the BNO055 FAQs addresses the problem, but white-washes the rationale:
https://learn.adafruit.com/adafruit-bno ... ensor/faqs

User avatar
MrTanaka64
 
Posts: 4
Joined: Tue Jul 19, 2022 12:25 am

Re: BNO055 not reading correct values

Post by MrTanaka64 »

I recently tested the sensor again just using an arduino nano though another calibration test and for some reason the accelerometer and magnetometer had a reading of 1 for a very short time despite me adjusting and holding the sensor to fit all the axis directions. I didn't do anything differently compared to the previous tests that I tried as per your recommendations. Are there any ideas on what this could mean? Or could this just justify the sensor being faulty?
Attachments
Screenshot 2022-07-20 160205.jpg
Screenshot 2022-07-20 160205.jpg (32.78 KiB) Viewed 523 times

User avatar
gammaburst
 
Posts: 1013
Joined: Thu Dec 31, 2015 12:06 pm

Re: BNO055 not reading correct values

Post by gammaburst »

I haven't used an Arduino Nano, but I think it has an Atmel 328P like an Arduino Uno. That sounds fine.

I don't recognize the program you're now running - unidentified X Y Z values on the same line as CALIBRATION values. The BNO's calibration values are always strange, so I suggest ignoring calibration for now and concentrating on the data values. The data values normally come alive almost immediately even if you don't do any calibration steps.

Can you recreate the working project that you had a year ago with the rawdata example? If you still have that project, and it no longer works, then that suggests something broke. Try replacing components until it works. (I usually buy two or three of everything unless it's expensive.)

If you suspect a broken BNO055, try measuring the DC current flowing into its VIN pin. I've seen a good BNO typically draws about 9mA before and during configuration, then about 13mA while it's running and outputting data.

As a student, perhaps you can borrow an oscilloscope that has an I2C decoder, and examine your I2C bus to see what's going wrong. That could be an extra-credit learning exercise!

Just double-checking ... You understand that gyros tell you rotation rate and not orientation, yes?

Also, I don't see a BNO055 spec that says how much linear acceleration the gyros can tolerate while remaining accurate. Some rockets have lots of acceleration.

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Arduino products from Adafruit”