Bosch Sensortec Community

    Showing results for 
    Search instead for 
    Did you mean: 

    wrong read out accelerometer BMA280

    wrong read out accelerometer BMA280

    New Poster


    For a research project, I am currently trying to read the acceleration data from the BMA280. This chip is used by silabs on there WSTK expansion board. At this moment I'm following a complete procedure to initialize the accelerometer.

    1. Perform self test
      1. Check if difference from read out of +X en -X is bigger than 800mg (answer: check)
      2. Check if difference from read out of +Y en -Y is bigger than 800mg (answer: check)
      3. Check if difference from read out of +Z en -Z is bigger than 400mg (answer: check)
    2. Soft reset the accelerometer
      1. wait 1,5 sec
    3. Initialize the accelerometer to my preferences
    4. Perform Fast compensation
      1. Clear offset register
      2. Set offset compensation to X: 0g, Y: 0g, Z:+1g, BW 1%
      3. X-axis calibration
      4. Y-axis calibration
      5. Z-axis calibration
      6. Read offset X              my answer: x = -31 mg
      7. Read offset Y              my answer:  y = -15 mg
      8. Read offset Z             my answer:  z = 0 mg
    5. init done

    The values afterwards are x=+-20mg, y=+-2mg en z=+- -19mg. I expected the values would be x=+-0g, y=+-0g en z=+- -1g when the chip is laying flat on my desk.

    I convert the acceleration data in this way.



    volatile float factor = 0.488; // 8000/2^14 mg/LSB
    // X-Axis in 0x02-0x03
    LSBx = BMA280_read_register(USART1, BMA280_ACCD_X_LSB);
    LSBx = LSBx >> 2;
    MSBx = BMA280_read_register(USART1, BMA280_ACCD_X_MSB);
    tmpx = (uint16_t)((MSBx << 6) | LSBx);
    acceleration[0] = (float) tmpx * factor;


    Can somebody confirm me If this is correct? Or give me the correct init from the accelerometer?

    Thank you in advance

    Best Regards


    3 REPLIES 3

    Community Moderator
    Community Moderator


    Thanks for your inquiry. Please see the attached "How to perform BMA253 self-test.pdf" and "How to do BMA253 inline calibration.pdf" which can be applied to BMA280 as well.

    Due to the noise of intenral ADC, after inline calibration BMA280 x/y/z measurements or outputs will not be exactly at 0g and +1g when it is stationary and flat on your table. Instead, they should be very close to 0g and +1g. For example, if you select BMA280 BW to 125Hz which is 250Hz output data rate, then you should see the x/y/z outputs within +/-5mg with regrad to 0g and +1g.



    Thanks for the reply.

    I checked both PDF and adjusted my code. When I perform the self test I get values (x=12599LSB, y=13235LSB, z=13589LSB) So the self test passes. The calibartion (fast compensation +-2G) gave me (x=-5LSB, y=1LSB, z=-2LSB).  But when the chip is flat on my desk with a refresh rate of 125Hz I get these values:

    x: 16,0 mg y: 51,172 mg z: -25,252 mg
    x: 15,0 mg y: 53,216 mg z: -21,240 mg
    x: 17,0 mg y: 54,116 mg z: -19,240 mg
    x: 18,0 mg y: 54,16 mg z: -23,252 mg
    x: 20,0 mg y: 50,184 mg z: -20,96 mg

    So I think, I do something wrong with the conversion of LSB to g or mg.




    volatile uint16_t tmpx = 0, tmpy = 0, tmpz = 0;
    volatile uint8_t MSBx = 0, LSBx = 0, MSBy = 0, LSBy = 0, MSBz = 0, LSBz = 0;
    volatile float factor = 0.488; //mg/LSB 8000/2^14 for range of +-4G
    // X-Axis in 0x02-0x03
    LSBx = BMA280_read_register(USART1, BMA280_ACCD_X_LSB);
    MSBx = BMA280_read_register(USART1, BMA280_ACCD_X_MSB);
    tmpx = (uint16_t)(((MSBx <<  | LSBx) >> 2);
    acceleration[0] = (float) tmpx * factor;




    Is this the correct way?

    Thx for the previous help!!

    Best regards


    I found the solution.

    // X-Axis in 0x02-0x03
    LSB = BMA280_read_register(USART1, BMA280_ACCD_X_LSB);
    MSB = BMA280_read_register(USART1, BMA280_ACCD_X_MSB);
    Ax = (int16_t) ((MSB << 😎 | LSB);
    Ax = Ax >> 2;
    Acceleration[0] = ((float) Ax) * factor; //0,244mg/LSB

    Thx for the help