#### Bosch Sensortec Community

cancel
Showing results for
Did you mean:
SOLVED

## BHI260 Gravity Vector unwanted offset appears

Long-established Member

## BHI260 Gravity Vector unwanted offset appears

Hello,

I'm using a BHI260AB chip with an STM32 as the host processor.

To start I want to do something very simple now, which is basically taking the gravity vector measurement and with that vector figure out the inclination angle of my device.

So, I have the BHI chip with the following references (in red):

Then we have the gravity:

Then when the chip has a certain inclination:

In this picture, gravity has just two components (YZ) because the drawing shows a rotation around the X-axis (it's easier for me to draw this 2D scheme). But let's assume that the chip can have any orientation and the gravity is decomposed into the three axes.

On my project, I have an initial position of the device which is when the BHI chip is in the following orientation:

This orientation is considered to be the 0° inclination. And the inclination angle is calculated by doing the following:

``alfa = arcsin(gz / g);``

Where gz is the module of the Z component of the gravity and g is the module of the gravity.

So I do that calculation with my STM32 and I was surprised when I placed the device in the initial position (picture 4). My alfa angle was showing of inclination. I was expecting the angle not to be 0°, but not to have such an error in the initial position.

Inspecting the g components got from the BHI chip in the initial position I got the following:

x = 0.017333984375 g

y = -0.992431640625 g

z = 0.120361328125 g

I'm very surprised by the Z component. It should be very low, but it's not.

As a comment, I didn't run any calibration on the chip or any offset correction before these calculations. I just connected the chip and used it as it was. But still, I'm concerned about the magnitude of the error.

Is there something that I should do before using the gravity vector?

I didn't try the same by using the accelerometer values instead of the gravity virtual sensor. But I guess the gravity virtual sensor is based on the accelerometer readings. So, It should be the same.

I hope anybody can help me.

Thanks!

4 REPLIES 4
Community Moderator

## Re: BHI260 Gravity Vector unwanted offset appears

Hello,

xyz values for gravity is correct as root( x2 + y2 + z2) = 1. So, two things you can do for more accurate value.

If there is offset, the gavity value of root( x2 + y2 + z2) exceeds 1.

So, I think you need to calibrate BHI260 as below youtube clip. (It's BNO055, but same method as BHI260AB)

And also, please check whether you set BHI260 properly.

Thanks,

Long-established Member

## Re: BHI260 Gravity Vector unwanted offset appears

Hello Minhwan,

In the Youtube video, I can see that they use the "Bosch Development Desktop" application for doing the calibration.

In my case, I use an STM32 as a host processor connected to the BHI260AB over SPI. I don't understand very well how should I do with my STM32 for calibrating the gravity virtual sensor.

Right now what I do with the STM32 is the following:

• Reset the BHI chip
• Run a self-test on the accelerometer
• Run a self-test on the gyroscope
• Configure gravity virtual sensor with a sample rate of 25Hz
• Periodically read the gravity vector

So, here are some questions:

1. What should I do for calibrating the gravity vector? is there some command that I must send to the BHI260AB? is not clear in the datasheet.
2. In the case that I use more virtual sensors (I plan to use the Game Rotation Vector too), should I run a calibration routine for each of them separately?
3. Is it necessary to run the calibration routine (shown in the video) every time the device is turned on (every time the firmware is downloaded to the BHI chip)?

Thanks!

Long-established Member

## Re: BHI260 Gravity Vector unwanted offset appears

Hello Minhwan,

Do you have any update on this topic?

Thanks!

Long-established Member

## Re: BHI260 Gravity Vector unwanted offset appears

I finally found the dynamic calibration is automatically performed by the Fuser2 Core as soon as a virtual sensor is enabled.