adafruit / Adafruit_BNO08x

Arduino library for BNO08x
Other
37 stars 14 forks source link

Cannot create more than one instance #32

Open dhalbert opened 1 month ago

dhalbert commented 1 month ago

Attempting to create more than one Adafruit_BNO08x fails, because i2c_dev is a static global, and gets discarded and re-created on the second call to the Adafruit_BNO08x constructor. I believe the i2c_dev should be a field in the device object.

See https://discord.com/channels/327254708534116352/537365760008257569/1273319381597687828 for a thread about this.

dhalbert commented 4 weeks ago

I'm not sure if the sensor_id argument is necessary, since different instantiations could be distinguished by object identity.

dhalbert commented 4 weeks ago

This is not so easy to fix, because the underlying library we use, https://github.com/ceva-dsp/sh2, is not re-entrant and only supports one sensor at a time. The SparkFun library is derived from ours; this problem was brought up there: https://github.com/sparkfun/SparkFun_BNO08x_Arduino_Library/issues/3 and then an issue was opened on the original library: https://github.com/ceva-dsp/sh2/issues/9 This was November 2023, not sure if there will be any movement on this.

iLoveAndyBaker commented 3 weeks ago

It's not just one sensor per bus either - it's just ONE sensor. Period.

VICLER commented 3 weeks ago

I found out that the SparkFun BNO080 old library (https://github.com/sparkfun/SparkFun_BNO080_Arduino_Library) works well with more than one BNO085 sensors on i2c bus. There are 2 addresses, so you can get up to 4x bno085 working on esp32 (with 2x i2c ports). But it does not work with SPI for some reason.. For my project I need 5x sensors, so I am using sparkfun bno080 for 4x sensors over i2c and one with sparkfun bno08x over spi.