2025-07-08 7:48 AM
Hi everyone,
I’m developing an application that tracks the path of a device using the ISM330BX IMU and sensor fusion. I’ve based my implementation on ST’s GitHub example for sensor fusion, and the rotation outputs appear to respond correctly when I move the sensor. Pitch and roll are stable, and the orientation updates as expected.
However, I’m seeing significant drift in the yaw when the device is stationary. I understand that yaw is difficult to estimate accurately with only a 6-axis sensor (no magnetometer), but I’ve observed a big difference between my application and the ISM330BX demo board (STEVAL-MKI245KA) running in MEMS Studio.
For example:
I’m trying to figure out what could be causing the higher drift in my setup. Is there anything I can do in the code or configuration to reduce yaw drift?
Any suggestions on what settings or techniques might help would be greatly appreciated.
Thanks in advance!
my power up code is:
void gyro_powerup()
{
ism330bx_reset_t rst;
ism330bx_sflp_gbias_t gbias;
dev_ctx.write_reg = platform_write;
dev_ctx.read_reg = platform_read;
dev_ctx.mdelay = platform_delay;
dev_ctx.handle = NULL;
ism330bx_device_id_get(&dev_ctx, &whoamI);
if (whoamI != ISM330BX_ID)
{
ESP_LOGE(TAG, "Wrong WHOAMI: 0x%02X", whoamI);
return;
}
ism330bx_reset_set(&dev_ctx, ISM330BX_RESTORE_CTRL_REGS);
do
{
ism330bx_reset_get(&dev_ctx, &rst);
} while (rst != ISM330BX_READY);
ism330bx_sflp_configure(&dev_ctx);
/* Enable Block Data Update */
ism330bx_block_data_update_set(&dev_ctx, PROPERTY_ENABLE);
ism330bx_xl_full_scale_set(&dev_ctx, ISM330BX_8g);
ism330bx_gy_full_scale_set(&dev_ctx, ISM330BX_4000dps);
/*
* Set FIFO watermark (number of unread sensor data TAG + 6 bytes
* stored in FIFO) to FIFO_WATERMARK samples
*/
ism330bx_fifo_watermark_set(&dev_ctx, 32);
/* Set FIFO batch of sflp data */
fifo_sflp.game_rotation = 1;
fifo_sflp.gravity = 1;
fifo_sflp.gbias = 1;
ism330bx_fifo_sflp_batch_set(&dev_ctx, fifo_sflp);
/* Set FIFO mode to Stream mode (aka Continuous Mode) */
ism330bx_fifo_mode_set(&dev_ctx, ISM330BX_STREAM_MODE);
/* Set Output Data Rate */
ism330bx_xl_data_rate_set(&dev_ctx, ISM330BX_XL_ODR_AT_30Hz);
ism330bx_gy_data_rate_set(&dev_ctx, ISM330BX_XL_ODR_AT_30Hz);
ism330bx_sflp_data_rate_set(&dev_ctx, ISM330BX_SFLP_30Hz);
ism330bx_sflp_game_rotation_set(&dev_ctx, PROPERTY_ENABLE);
gbias.gbias_x = 0.0f;
gbias.gbias_y = 0.0f;
gbias.gbias_z = 0.0f;
ism330bx_sflp_game_gbias_set(&dev_ctx, &gbias);
}