Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 
    SOLVED

    BMI160 Shuttle Board With the Developed Library in Arduino Uno issue

    Highlighted
    Established Member

    BMI160 Shuttle Board With the Developed Library in Arduino Uno issue

    Hi

    I am using the BMI160 shuttle board with Arduino Uno over SPI.  Also, I am using the Driver developed by Hanyazou https://github.com/hanyazou/BMI160-Arduino. The connection is okay but the gyro results are incorrect (random data). Also, the device id is returned 7F which means somewhere in the code or connection is wrong. Can you please help me resolve the issue?

    Please see the code below (The code is the example in the Hanyazou GitHub).

     

     

     

    #include <BMI160.h>
    #include <BMI160Gen.h>
    #include <CurieIMU.h>
    
    //const int i2c_addr = 0x69;
    
    
    void setup() {
      Serial.begin(9600); // initialize Serial communication
      while (!Serial);    // wait for the serial port to open
    
      // initialize device
      Serial.println("Initializing IMU device...");
      BMI160.begin(BMI160GenClass::SPI_MODE, /* SS pin# = */10);
      //BMI160.begin(BMI160GenClass::I2C_MODE);
      uint8_t dev_id = BMI160.getDeviceID();
      Serial.print("DEVICE ID: ");
      Serial.println(dev_id, HEX);
    
      // Set the accelerometer range to 250 degrees/second
      BMI160.setGyroRange(125);
      Serial.println("Initializing IMU device...done.");
    }
    
    void loop() {
      int gx, gy, gz;         // raw gyro values
    
      // read raw gyro measurements from device
      BMI160.readGyro(gx,gy,gz);
    
      // display tab-separated gyro x/y/z values
      Serial.print("g:\t");
      Serial.print(gx);
      Serial.print("\t");
      Serial.print(gy);
      Serial.print("\t");
      Serial.print(gz);
      Serial.println();
    
      delay(1);
    }
    
    float convertRawGyro(int gRaw) {
      // since we are using 250 degrees/seconds range
      // -250 maps to a raw value of -32768
      // +250 maps to a raw value of 32767
    
      float g = (gRaw * 250.0) / 32768.0;
    
      return g;
    }

     

     

     

     

    And this is the connection photo. 

    arduino bmi160 shuttle board.png

     

    Your help is truly appreciated!

    Thanks

    Saber

    6 REPLIES 6
    Community Moderator

    Re: BMI160 Shuttle Board With the Developed Library in Arduino Uno issue

    The HW connection in the image looks OK. 

    I believe the SW code itself is also OK.

    But from the result,  the SPI connection is not setup correctly.

    So, can you share the logic analyzer result for better understanding this issue?

    Highlighted
    Established Member

    Re: BMI160 Shuttle Board With the Developed Library in Arduino Uno issue

    Hi

    Thanks for your reply. 

    Please kindly find the logic analyzer for the pins. This is the zoomed out photo.

    logic analyzer.png

    Based on the datasheet the data transmission occurs when the CS is low, but here when the CS is low, almost nothing happens. Do you have any idea where the problem is? 

    Thanks

     

    Highlighted
    Community Moderator

    Re: BMI160 Shuttle Board With the Developed Library in Arduino Uno issue

    When the CS is low,  we need also the host to send out the clock,  and the register address.  Then our sensor will response for it.

    From your plotter,  i can't see any data from host for read / write action.  then there is also no ACK / response from our sensor. 

    We verify the example code at Arduino DUE platform,  which works properly.

    So you need double check at your side for the SPI host configuration. 

     

    Highlighted
    Established Member

    Re: BMI160 Shuttle Board With the Developed Library in Arduino Uno issue

    Thanks for your reply. 

    I am using the exact example here.

    Also, the SPI connections are the same as I showed in the first post:

    pin 1: VDD:3.3 V

    pin 2: VDDIO: 3.3 V

    pin 3: GND

    pin 4: MISO

    pin 5: MOSI

    pin 6: SCK

    pin 7: CS

    And all other pins are unconnected. Are they all correct? So it is strange that it is not working. 

    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