Bosch Sensortec Community

    Showing results for 
    Search instead for 
    Did you mean: 

    How to use the same sensor API with several sensors (BNO055)

    How to use the same sensor API with several sensors (BNO055)



    I'm trying to use the Bosch Sensortech API for the BNO055 sensor. The API can be found here. I would like to use two BNO055 sensors on the same I2C bus (each with different addresses) or in different I2C buses (in this case with the same address).

    1. After reading the API, I understood I can create a structure to store the device information:

    struct bno055_t myBNO;

    2. Then link my MCU I2C driver functions to the API communication function pointers:

    myBNO.bus_read = BNO055_I2C_bus_read();
    myBNO.bus_write = BNO055_I2C_bus_write();
    myBNO.delay_msec = delay;

    3. Configure the correct I2C address of my device:

    myBNO.dev_addr = BNO055_I2C_ADDR1;

    4. And finally do API initialization by passing the reference of my object with device information:


    Inside of the API file (bno055.c) we can se a pointer of type bno055_t that will point to my myBNO device. And from now on, all API Calls are related to this device. So if I try to do the point 4) again but with the reference to my second sensor, lets say:


    The API just lost the information of the first device and will work only for the second one.

    So if I have another BNO055 sensor with another I2C address how can I use this API?
    Or if I have another BNO55 sensor with the same address but in a different I2C bus how can I use this API?

    Creating multiple objects of type bno055_t is possible. Setting a different address and linking different I2C driver functions (depends on which I2C0 or I2C1 bus I am using) is also possible. But then when I initialize the API using bnO055_init(), I am only able to do this once with only one device's information.

    Any suggestion?

    5 REPLIES 5

    Community Moderator
    Community Moderator

    Hi gcb,

    The I2C device addresses of two BNO055 must be different. Whether the two BNO055 are on one I2C bus or different bus, you can refer to the following examples.

    struct bno055_t bno055-1;
    struct bno055_t bno05-2;

    s8 I2C_routine-1(void)
    bno055.bus_write = BNO055_I2C_bus_write-1;
    bno055.bus_read = BNO055_I2C_bus_read-1;
    bno055.delay_msec = BNO055_delay_msek;
    bno055.dev_addr = BNO055_I2C_ADDR1;

    return BNO055_INIT_VALUE;

    s8 I2C_routine-2(void)
    bno055.bus_write = BNO055_I2C_bus_writ-2;
    bno055.bus_read = BNO055_I2C_bus_read-2;
    bno055.delay_msec = BNO055_delay_msek;
    bno055.dev_addr = BNO055_I2C_ADDR2;

    return BNO055_INIT_VALUE;

    Also, the Bosch team should be careful when writing documentation on github. In the BNO055 repository there are many errors. Some { in the wrong place, the support.c file sometimes spoke in I2C, sometimes in SPI... it's quite confusing.

    Community Moderator
    Community Moderator

    Hi gcb,

    This is a reference code. You can modify it based on this code.


    I understand it's just a reference code to use. But at least it should conform to what the datasheet indicates.

    The BNO055 datasheet indicates in Table 3-6 that the switching time from CONFIG MODE to another operating mode is 7ms and that the switching time from any operating mode to COFIGMODe is 19ms. However, in your API you have defined the following in the .h file:
                       #define BNO055_MODE_SWITCHING_DELAY 600
    And in the .c file when implementing the bno055_set_operation_mode() function say somewhere:
                      /* Config mode to other  operation mode switching  required delay of 600ms*/

    There is a lot of discrepancies between your API implementation and the sensor datasheet.

    Best regards