Bosch Sensortec Community

    Showing results for 
    Search instead for 
    Did you mean: 

    Setting Range with I2c protocol

    Setting Range with I2c protocol

    New Poster

    Hello everyone,

    I am currently gathering data from all the BMIs in shuttleboard versions. I have set the range for the acceleration via the smbus2 proposed by Python. However, my acceleration measures add up to 11,100 mg(even when taking into account biases and noises that is not 9.81 m/s^2 so 1000mg or 1g).

    Hence, I believe that there may be a problem when setting the acceleration range. Indeed, when using the Python smbus2 I can only write bytes (at minimum one) but the range is set by writing only one bit to the bus.

    Does anyone know how to solve this problem?

    Thanks in advance,


    Anthony Guillard

    2 REPLIES 2

    Community Moderator
    Community Moderator

    You can read out the register then marked the other bits and only change the bits for changing the range. 

    After that, you write back the whole register byte. 

    It is a common solution for your problem. 

    For you read out, can you tell me which BMI chips you are using now? 

    For the acceleration in the BMI, there is different resolution so there is 12 bits / 16 bits accleration data,  you need figure out the sensitivity through the related datasheet.  if it is 12 bits, then you can not convert the sensor data with whole 2 bytes read out value. 

    Dear Vincent,

    Thank you so much for your help. That is what I have just implemented.
    I am using the BMI088 as of right now before moving on to the other ones. The acceleration is represented by 16 bits.

    After having implemented your method I have realised something else: the datasheet mentions that the conversion from LSB to mg is done in the following way

    Acc_mg = Acc_int_Y/f32768*1000*2**(<0x41> + 1)*1.5

    Where <0x41> is the content of that said register. I am using the BMI088 in +/-3g mode thus the register output is 0. I was previously using the range setting (so 3 here) instead of the register output. However, both solutions yield odd results.
    Did I make a mistake in the conversion process?


    Anthony Guillard