Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Library: Can't initialize two BNO086 on one I2C bus #3

Open
iLoveAndyBaker opened this issue Sep 19, 2023 · 11 comments
Open

Library: Can't initialize two BNO086 on one I2C bus #3

iLoveAndyBaker opened this issue Sep 19, 2023 · 11 comments
Assignees

Comments

@iLoveAndyBaker
Copy link

Devices ACK on addresses 0x4A and 0X46, but library won't allow both to init.

RP2040 (As KB2040)

Steps to reproduce

Daisychain two BNO086 via Qwiic connectors, jump address pin on one unit, cut pullups on end unit.

Run example code:


#include "SparkFun_BNO08x_Arduino_Library.h"  // CTRL+Click here to get the library: http://librarymanager/All#SparkFun_BNO08x
BNO08x myIMU;
BNO08x yourIMU;

void setup() {
  Serial.begin(115200);
  delay(5000);
  Serial.println();
  Serial.println("BNO08x Read Example");

  Wire.begin();
  Wire.setClock(100000); //Increase I2C data rate to 400kHz

  if (myIMU.begin(0x4B,Wire,-1,-1) == false) {
    Serial.println("First BNO08x not detected at default I2C address. Check your jumpers and the hookup guide. Freezing...");
    //while (1)
      ;
  } else{
    Serial.println("First IMU found!");
  }

  if (yourIMU.begin(0x4A,Wire,-1,-1) == false) {
    Serial.println("Second BNO08x not detected at default I2C address. Check your jumpers and the hookup guide. Freezing...");
    while (1)
      ;
  } else{
    Serial.println("Second IMU found!");
  }

Expected behavior

Both chips ACK and program continues with begin == false. BUT...

Actual behavior

Second to be init'd will ack, but begin returns false

Device acknowledged at 75
First IMU found!
Device acknowledged at 74
Second BNO08x not detected at default I2C address. Check your jumpers and the hookup guide. Freezing...

I changed the library Sparkfun_BNO8x_Arduino_Library.cpp to call out the address that ACK'd

    	return (false); 

// CHANGED THIS SERIAL MESSAGE
    Serial.print(F("Device acknowledged at "));
    Serial.println(_deviceAddress);
    //delay(1000);

    _HAL.open = i2chal_open;

Re-ordering the initialization of the boards doesn't help. The one that goes SECOND fails.

BNO08x Read Example
Device acknowledged at 74
First IMU found!
Device acknowledged at 75
Second BNO08x not detected at default I2C address. Check your jumpers and the hookup guide. Freezing...
@iLoveAndyBaker
Copy link
Author

iLoveAndyBaker commented Sep 20, 2023

Update: Even tried on separate I2C busses, first device to .begin will initialize, second will not. Reorder and it's still the first one in the code will work, the next will not.

@lewispg228
Copy link
Member

Hi @iLoveAndyBaker ,
Sorry, but this can only support a single device on the bus. See here. This is due to the fact that the CEVA-DSP SH2 driver has some static methods and static variables. Not sure if this is even possible with the SHTP protocol, but if you wanted to, it might be worth starting another issue on their repo requesting this feature.

@rah2501
Copy link

rah2501 commented Nov 28, 2023

I raised an issue with the SH2 library: ceva-dsp/sh2#9

Is the closure of this SparkFun_BNO08x_Arduino_Library issue a signal that you're unwilling to add support for more than one sensor? Do you consider the limitation of running only a single sensor to be a bug that should be fixed? If so, please reopen this issue.

@lewispg228
Copy link
Member

Hi @rah2501 , Thank you for submitting the issue and PR on the SH2 Library. When CEVA responds and/or adds in the ability to do multiple sensors, we would be excited to adapt our library to also work with multiple sensors. For now, we will leave this issue open. Thanks again and we look forward to seeing what CEVA says.

@rah2501
Copy link

rah2501 commented Oct 9, 2024

we look forward to seeing what CEVA says

FYI, CEVA have completely ignored the github issue, the PR I raised and generally seem to have stopped communicating with the community. I even did some digging and found the email address of one of the engineers (David Wheeler) and tried emailing them but again, no response. Disappointing.

Edit: To make it worse, a commit was made by David Wheeler to the SH2 github repository the day after I raised the issue. Feels like a bit of a "fsck you". Perhaps they didn't appreciate people pointing out flaws in their handiwork.

@iLoveAndyBaker
Copy link
Author

I have collected the following: In the SH2 library:
@rah2501 states that: The BNO08x library calls sh2_service() which uses another global variable named _sh2 for sensor-specific state.

@rah2501 did some changes to sh2.h at ceva-dsp/sh2#10 but just copying that file over still wouldn't make it compile, and that's the extent of my expertise (I'm more of a project manager in this respect)

So even though it's probably not best practices to just patch up the SH2.h that lives in the Sparkfun library, I kinda don't see how this is going to get resolved in the usual proper manner without support from the upstream CEVA people....without simply patching up this version that's sitting here in the Sparkfun library. There's nothing stopping me from doing this on my own hard drive either, but that's not very useful to anybody else.

Oh and besides the whole static methods issue, there might need to be a need to call out the INT and RST per device too, because I don't see how #define BNO08X_INT xxx is going to work unless it's common across this whole SHTP bus, which I confess I hardly understand its purpose.

@iLoveAndyBaker
Copy link
Author

CEVA says fork it and fend for ourselves.

ceva-dsp/sh2#9 (comment)

@julkatpen
Copy link

Hello everyone, did you fork sh2 in order to fix this problem?

I am trying to connect 8 BNO086 via an I2C Multiplexer using the sparkfun library but i am running in to the same error that you described. I am a mechanical engineering student and writing my bachelor thesis, therefore i am sadly not able to write all of the code by myself. If anything worked out for you I would be very happy if you would share it with me.

@rah2501
Copy link

rah2501 commented Jan 14, 2025

Hello everyone, did you fork sh2 in order to fix this problem?

No.

If anything worked out for you I would be very happy if you would share it with me.

I shelved my project because of this issue.

Unless you have the software development resources to reimplement the driver, the BNO0xx chips are essentially useless for proper engineering.

@julkatpen
Copy link

julkatpen commented Jan 16, 2025 via email

@julkatpen
Copy link

I got it work for my purposes. I will post the fix so that anyone who has the same issue can maybe use it.

The SparkFun_BNO08x_Arduino_Library library accesses the SH2 library, which uses the SHTP library, where there is a definition for MAX_INSTANCES (1) on line 148. When .begin() is applied to the sensor object, multiple steps in the SparkFun_BNO08x_Arduino_Library and the SH2 library result in the SHTP library requesting a new instance. However, since the old version only allows one instance, initialization fails, making usage impossible afterward. When this value is adjusted to the desired number of sensors to be operated via a multiplexer, initialization and data output work as expected.
It is possible that this modification may lead to issues in other operating modes and require further adjustments to the library.

Here is the exact process from MAX_INSTANCES() to .begin():

shtp.c:
MAX_INSTANCES(1)
used in getInstance
used in shtp_open
sh2.c:
used in sh2_open
SparkFun_BNO08x_Arduino_Library.c:
used in _init
used in begin
Your Code:
uses .begin in initializeSensor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants