Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 

    BMI160 undeclared values error

    BMI160 undeclared values error

    herez1
    Member

    Hi,

    I use BMI160 with STM32F4. I have driver from Bosch Sensortec (https://github.com/BoschSensortec/BMI160_driver) 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:

    herez1_0-1648153167271.png

    Then, I want to use these values from bmi160_defs_h:

    herez1_2-1648153360115.png

    herez1_3-1648153466663.png

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

    Please help.

    5 REPLIES 5

    FAE_CA1
    Community Moderator
    Community Moderator

    Hi,

    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.

    Thanks.

    Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist