Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 9 of 9

Thread: Error Using BNO085 with Teensy 4.0

  1. #1

    Error Using BNO085 with Teensy 4.0

    I have a Teensy 4.0 and an Adafruit BNO085 IMU (link here) that I am trying to use together. I'm trying to hook up the BNO085 over I2C. I'm using the Arduino IDE and Teensyduino 1.53. Unfortunately, I'm unable to run any of the sample programs and the only output I get in the serial monitor is "Failed to find BNO08x chip." I've tried running a I2C scanner and it returns the proper address of the BNO085 board (0x4A), so I'm convinced that this is a software issue and not an issue with the Teensy or the BNO085. I've tried to run both of the included sample programs with the Adafruit BNO08x library without any luck with either. I also looked into the library cpp file and found that the Adafruit_Bno08x::_init(int32_t sensor_id) method errors on the following section of code:

    Code:
      memset(&prodIds, 0, sizeof(prodIds));
      status = sh2_getProdIds(&prodIds);
      if (status != SH2_OK) {
        return false;
      }
    Evidently status is not equal to SH2_OK, so the init method returns false. Below is the source code for one of the example scripts I tried, rotation_vector.ino:

    Code:
    // Basic demo for readings from Adafruit BNO08x
    #include <Adafruit_BNO08x.h>
    
    // For SPI mode, we need a CS pin
    #define BNO08X_CS 10
    #define BNO08X_INT 9
    
    #define BNO08X_RESET 5
    
    Adafruit_BNO08x  bno08x(BNO08X_RESET);
    sh2_SensorValue_t sensorValue;
    
    void setup(void) {
      Serial.begin(115200);
      while (!Serial) delay(10);     // will pause Zero, Leonardo, etc until serial console opens
    
      Serial.println("Adafruit BNO08x test!");
    
      // Try to initialize!
      if (!bno08x.begin_I2C()) {
      //if (!bno08x.begin_UART(&Serial1)) {  // Requires a device with > 300 byte UART buffer!
      //if (!bno08x.begin_SPI(BNO08X_CS, BNO08X_INT)) {
        Serial.println("Failed to find BNO08x chip");
        while (1) { delay(10); }
      }
      Serial.println("BNO08x Found!");
    
      for (int n = 0; n < bno08x.prodIds.numEntries; n++) {
        Serial.print("Part ");
        Serial.print(bno08x.prodIds.entry[n].swPartNumber);
        Serial.print(": Version :");
        Serial.print(bno08x.prodIds.entry[n].swVersionMajor);
        Serial.print(".");
        Serial.print(bno08x.prodIds.entry[n].swVersionMinor);
        Serial.print(".");
        Serial.print(bno08x.prodIds.entry[n].swVersionPatch);
        Serial.print(" Build ");
        Serial.println(bno08x.prodIds.entry[n].swBuildNumber);
      }
    
      setReports();
    
      Serial.println("Reading events");
      delay(100);
    }
    
    // Here is where you define the sensor outputs you want to receive
    void setReports(void) {
      Serial.println("Setting desired reports");
      if (! bno08x.enableReport(SH2_GAME_ROTATION_VECTOR)) {
        Serial.println("Could not enable game vector");
      }
    }
    
    
    void loop() {
      delay(10);
    
      if (bno08x.wasReset()) {
        Serial.print("sensor was reset ");
        setReports();
      }
      
      if (! bno08x.getSensorEvent(&sensorValue)) {
        return;
      }
      
      switch (sensorValue.sensorId) {
        
        case SH2_GAME_ROTATION_VECTOR:
          Serial.print("Game Rotation Vector - r: ");
          Serial.print(sensorValue.un.gameRotationVector.real);
          Serial.print(" i: ");
          Serial.print(sensorValue.un.gameRotationVector.i);
          Serial.print(" j: ");
          Serial.print(sensorValue.un.gameRotationVector.j);
          Serial.print(" k: ");
          Serial.println(sensorValue.un.gameRotationVector.k);
          break;
      }
    
    }
    If anyone has any insight or suggestions on what could be the issue I would really appreciate your input.

  2. #2
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    7,870
    I would probably keep adding more debug messages in the library and see where it is failing. I have the Sparkfun BNO080, but not this one... At some point may try to pick up one.

    Not sure what else yet. But for example which of the two calls in the _init is failing?

    Do you have an reset pin connected? And specified in constructor? If not might try that? Not sure how much that might help.

    Again I would keep adding debug outputs until the failure point can be localized.

  3. #3
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,878
    According to the product page posted it is backward compatible with the BNO080 (??). You could try and use the sparkfun BNO080/085 library as well https://github.com/sparkfun/SparkFun...rduino_Library.

    But I am making several assumptions - so make sure you check the things listed by @KurtE.

    I just ordered one from Adafruit - not sure when it will get here though.

  4. #4
    Thank you very much for the advice @KurtE and @mjs513! I ended up trying it with the Sparkfun BNO080 library and it seemed to be working fine! I ran a few of their example scripts and both worked without issue. I also found on the Adafruit forums that people were experiencing a similar issue, albeit with different boards (link here to the forum discussion and here to the GitHub ticket). This coupled with the fact that I was able to get results from the Sparkfun library make me think there's an issue with the Adafruit library for the board. The issue is still open on GitHub, so I'll be watching that to see what sort of solution they come up with and if that fixes the issue on the Teensy 4.0. Thanks again for your help!

  5. #5
    Senior Member
    Join Date
    Oct 2017
    Location
    Houston
    Posts
    448
    mjs513 beat me to it, was going to suggest sparkfun lib. i just got the adafruit 85 in as well, but am still busy with some SDR work so not sure when i'll get to it. the SPI interface did not work reliably on the 80 chip for me, so hopefully thats fixed.

  6. #6
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    7,870
    Quote Originally Posted by mjs513 View Post
    I just ordered one from Adafruit - not sure when it will get here though.
    I tried to order one, but Digikey does not have them, nor some of the other places and Adafruit still will not ship to my address (PMB).

  7. #7
    Just thought I'd give an update for anyone interested -- Adafruit recently updated their BNO08x library and their BNO085 board now works fine over I2C with the Teensy 4.0!

  8. #8
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,878
    Thanks for posting about the update. Just got my BNO085 tonight from Adafruit. Will probably solder tomorrow and test it.

  9. #9
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    7,870
    Quote Originally Posted by mjs513 View Post
    Thanks for posting about the update. Just got my BNO085 tonight from Adafruit. Will probably solder tomorrow and test it.
    Or you can try the QWIIC connector

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •