Bosch Sensortec Community

    Showing results for 
    Search instead for 
    Did you mean: 

    BMI160 undeclared values error

    BMI160 undeclared values error



    I use BMI160 with STM32F4. I have driver from Bosch Sensortec ( but i cannot get true value from sensor. I want to get gyro and accel values for x, y and z. I initialize the sensor. You can see here:


    Then, I want to use these values from bmi160_defs_h:



    But i get an error: 'x', 'y', 'z' undeclared, first use in this function. How can i fix it? 

    Please help.

    5 REPLIES 5

    Community Moderator
    Community Moderator


    You can use your I2C interface to access BMI160 registers directly without using the API source code. Please try the following step by step to get BMI160 accel and gyro data.

    1. Read BMI160 register 0x00 to see if you can get the chip_ID value of 0xD1 back. If yes, then it means your I2C read function works fine.

    2. Write value of 0x11 to command register 0x7E and then wait for 5ms. Now you can read register 0x03 to see if you can get the value of 0x10 back or not. If yes, then it means the accel is in normal mode and your I2C write function works fine as well.

    3. Write value of 0x15 to command register 0x7E and then wait for 55ms. Now you can read register 0x03 to see if you can get the value of 0x14 back or not. If yes, then it means both the accel and gyro are in normal mode.

    4. In the loop you can burst read from register 0x0C to 0x17. This means that in one I2C read transaction you read register 0x0C and repeat 12 times to get values from both accel and gyro data registers. Then you can combine the data bytes to signed integers. When you rotate the BMI160, these data should keep changing.

    5. If the above steps work fine, then you can go back to check your API code and refer to the example code on the Github that I showed you before.