Bosch Sensortec Community

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

    Problem reading BMI270 Accelerometer data

    Problem reading BMI270 Accelerometer data

    Menedee
    Member

    Hi,
    actually I want to read data from BMI270 of accelerometer with Arduino Nano.
    First of all I tried reading data by using this .ino file from github and the corresponding libraries.
    Unfortunately there is an error occurring while compiling which I am not getting solved.

     

    bmi2.h:1341:2: error: #endif without #if
    
    #endif /* BMI2_H_ */

     

    So I decided to try using just wire.h library.
    The I2C device is getting recocnised, when asking for ID I receive 0x24 which is correct too.


    I followed the instructions for normal power mode on page 23 of datasheet.
    I read the register values and they are written correct but the accelerometer values are still zero.
    This is the code I use for reading the LSB of the arduino:

     

    #include <Wire.h> //I2C Arduino Library
    
    #define address 0x69 //I2C 7bit address
    
    int response;
    
    void setup(){
    //Initialize Serial and I2C communications
    Serial.begin(9600);
    Wire.begin();
    delay(100);
    Wire.setClock(400000UL);
    
    // setting IMU270 in normal mode
    Wire.beginTransmission(address);
    Wire.write(0x7D); //PWR_Control Register
    Wire.write(0x0E); // enable acquistion of acc,gyro and temp
    Wire.endTransmission();
    
    Wire.beginTransmission(address);
    Wire.write(0x40); // Acc config
    Wire.write(0xA8); //
    Wire.endTransmission();
    
    Wire.beginTransmission(address);
    Wire.write(0x42); // Gyro config
    Wire.write(0xA9);
    Wire.endTransmission();
    
    Wire.beginTransmission(address); //
    Wire.write(0x7C); // PWR config
    Wire.write(0x02);
    Wire.endTransmission();
    }
    
    void loop()
    {
    Wire.beginTransmission(address);
    Wire.write(0x0C); // reading LSB of Acc
    Wire.requestFrom(address,1);
    
    if(Wire.available()<=1)
    {
    response = Wire.read();
    }
    Wire.endTransmission();
    Serial.println(response);
    delay(500);
    }

     

    Thanks in advance!

    7 REPLIES 7

    etracer
    Established Member

    Oh, I just realized what your problem is. You haven't uploaded the config into the device. On every boot you need to upload the full 8KB config file into the device as that's the microcode for the sensor. It won't do anything without it.

    I skipped this step in hope it's not necessary becuase I have to figure out how to implement the BMI270_main.tbin.

    I will try.
    Thank you!!

    Dear Menedee,

    I am currently working on Arduino Nano BLE sense Rev2 and struggling in reading BMI270 data. Right now I can use the official code: https://github.com/arduino-libraries/Arduino_BMI270_BMM150 to achieve 200Hz sample rate, however, it is far lower than the highest sample rate. So I want to write some code based on I2C.

    Do you have any progress? Would you mind teach me?

     

    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