2026-04-20 2:30 AM - last edited on 2026-04-20 2:38 AM by Andrew Neil
Hi everyone,
I am working on a project using BNO085 IMU sensor and STM32H7A3ZIT6Q. I have a single sensor working but stuck at 44Hz. The same sensor with SparkFun library on ESP32 achieves 1.2ms read time. I need help understanding why and how to match ESP32 performance on STM32.
Hardware:
Software:
STM32 performance achieved so far:
ESP32 performance with same sensor and SparkFun SH2 library:
This is a huge difference. 19ms on STM32 vs 1.2ms on ESP32 with the same SH2 library underneath.
Current STM32 sh2_hal_read implementation:
static int sh2_hal_read( sh2_Hal_t *self, uint8_t *pBuffer, unsigned len, uint32_t *t_us )
{
uint32_t timeout = HAL_GetTick() + 100;
while (HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_0) == GPIO_PIN_SET)
{
if (HAL_GetTick() > timeout) return 0;
}
HAL_StatusTypeDef status;
status = HAL_I2C_Master_Receive( &hi2c1, BNO085_ADDR, pBuffer, len, 100 );
if( status != HAL_OK ) return SH2_ERR_IO;
*t_us = HAL_GetTick() * 1000;
return len;
}Key observation: ESP32 SparkFun library reads 4 byte header first, then reads payload in 32 byte chunks with INT pin check between each chunk. Our STM32 reads entire packet in one HAL_I2C_Master_Receive call. Not sure if this is the cause of the difference.
What I have tried:
Questions:
Edited to apply source code formatting - please see How to insert source code for future reference.
2026-04-20 2:40 AM
What pullups are you using?
Have you looked at the I2C lines with an oscilloscope and/or logic analyser to see what's actually happening on the wires?
2026-04-20 7:32 AM
No can u please guide me how to do that I am new to the filed, I ma not aware how to do that
2026-04-20 9:52 AM
https://learn.sparkfun.com/tutorials/how-to-use-an-oscilloscope/all
https://courses.physics.illinois.edu/phys524/fa2023/phys524_units/2/2.pdf
This post has a good illustration of the effects of pullup value (too high; too low) on the I2C waveform.
2026-05-22 12:08 AM
Oscilloscope Capture — BNO085 + STM32H7A3, I2C1 @ 1 MHz
Scope: Tektronix TBS1022 | Date: 4-May-26 16:12
Channel settings:
What is visible on CH1 (yellow trace):
The yellow trace sits at a steady HIGH level for most of the window. It then drops sharply to LOW for a short duration, then returns to HIGH. This pattern repeats twice within the 50 ms window. The scope's auto-frequency measurement reads the period of this repeating HIGH-LOW-HIGH cycle as approximately 43.4 Hz.
What is visible on CH2 (cyan trace):
The cyan trace shows alternating regions. In some regions it is flat and quiet, sitting at a steady level. In other regions it becomes a dense, rapidly oscillating hash — this is the I2C clock toggling at 1 MHz, which is too fast to resolve individually at the 5 ms/div timebase so it appears as a filled block of activity. Within the 50 ms window, there are multiple such active blocks separated by quiet flat sections.
Spatial relationship between CH1 and CH2:
The transitions on the yellow trace (CH1) and the active hash blocks on the cyan trace (CH2) occur in the same regions of the time window. The quiet flat sections on CH2 correspond to the periods where CH1 is sitting steadily HIGH.
2026-05-22 12:58 AM
Your scope has a USB socket for a Flash Drive on the front:
You will be able to capture screenshots to this.
This will give much better results than photographs!
2026-05-24 6:08 AM - last edited on 2026-05-27 2:00 AM by Andrew Neil
Split from BNO085 not working with STM32L433RC-P nucleo board - which appears abandoned.
And subsequently merged into this thread.
Any update on this I am facing the same issue , did your issue got resolved if yes 1) at how uch frequency BNO085 is giving you the output and also can u please share your code and repo
2026-05-24 11:33 PM
can u please explain what do you mean by sequence handling
2026-05-24 11:35 PM
can someone please answer
2026-05-26 2:00 AM - edited 2026-05-26 3:08 AM
welcome to the forum
Rather than hijack someone else's old, abandoned thread it's better to start your own - then you will be able to mark the solution when the problem is resolved (only the person who started a thread can do that).
Please provide a full description of your actual setup, and what investigation/testing/debugging you have done so far -
see: How to write your question to maximize your chances to find a solution for best results.
Have you followed the suggestions given in the old thread?
@dinesh_ee_bme_72 wrote:can u please explain what do you mean by sequence handling
Not sure what you mean by that - I don't see "sequence handling" anywhere in the other thread ?
Are you referring to where @DUBEYISM said, "I also attempted different initialization sequences and delays, but the sensor remains unresponsive on STM32" ?
PS:
Is this the same issue here: BNO085 I2C with STM32H7A3 via SH2 library — stuck at 44Hz but ESP32 achieves 1.2ms read time ?
We’re moving the ST Community to a new platform to give you a better and more reliable community experience.