2025-07-08 6:05 AM - last edited on 2025-07-08 6:28 AM by Andrew Neil
VOID bno055_thread_entry(ULONG thread_input)
{
tx_thread_sleep(1000);
BNO086_Init();
while (1)
{
tx_thread_sleep(100);
}
}
I'm using the BNO086 IMU sensor with an STM32U575RGT6 MCU.
The schematic below shows the sensor connections.
The code I'm using is also provided below.
I am aware that the sensor communicates using the SH protocol format.
I'm trying to send custom packets over the I2C bus, but I haven't received any response from the sensor.
I connected the SDA and SCL lines to a logic analyzer, but there's no activity at all.
I couldn't read the sensor address over I2C in any way — I have no communication with the sensor whatsoever.
I reworked the hardware multiple times, replaced the sensor chip, but it still doesn't work.
I had previously used the BNO055 sensor successfully, but I can't get the BNO086 to work.
Is there something missing in my software configuration?
Do I need to configure anything additional in the .ioc file?
#ifndef __BNO086_H
#define __BNO086_H
#include <stdint.h>
#include <stdbool.h>
#define BNO086_I2C_ADDR (0x4A << 1) // SA0 = GND ise
#define SHTP_HEADER_LEN 4
#define CHANNEL_COMMAND 0x01
#define CHANNEL_EXECUTABLE 0x02
#define CHANNEL_CONTROL 0x03
#define CHANNEL_REPORTS 0x04
#define CMD_PRODUCT_ID 0xF9
#define CMD_GET_FEATURES 0xF8
#define CMD_SET_FEATURE 0xFD
void BNO086_Init(void);
void test_bno086_product_id(void);
#endif
#include <BNO055_IMU.h>
#include <string.h>
#include <stdio.h>
#include "stm32u5xx_hal.h" // kendi MCU modeline göre değiştir
#include "stm32u5xx_hal_i2c.h"
extern I2C_HandleTypeDef hi2c2;
void BNO086_SendPacket(uint8_t channel, uint8_t *payload, uint16_t length)
{
uint8_t buffer[SHTP_HEADER_LEN + 64] = {0};
uint16_t total_len = length + SHTP_HEADER_LEN;
// Header (2 byte length, 1 byte channel, 1 byte sequence = 0)
buffer[0] = total_len & 0xFF;
buffer[1] = (total_len >> 8) & 0xFF;
buffer[2] = channel;
buffer[3] = 0; // Sequence (şimdilik sabit)
memcpy(&buffer[4], payload, length);
HAL_I2C_Master_Transmit(&hi2c2, BNO086_I2C_ADDR, buffer, total_len, HAL_MAX_DELAY);
}
int BNO086_ReceivePacket(uint8_t *payload, uint16_t *length)
{
uint8_t header[SHTP_HEADER_LEN];
if (HAL_I2C_Master_Receive(&hi2c2, BNO086_I2C_ADDR, header, SHTP_HEADER_LEN, HAL_MAX_DELAY) != HAL_OK)
return 0;
uint16_t total_length = header[0] | (header[1] << 8);
*length = total_length - SHTP_HEADER_LEN;
if (*length > 64) return 0;
return HAL_I2C_Master_Receive(&hi2c2, BNO086_I2C_ADDR, payload, *length, HAL_MAX_DELAY) == HAL_OK;
}
void BNO086_TestProductID(void)
{
uint8_t payload[1] = { CMD_PRODUCT_ID };
uint8_t response[64] = {0};
uint16_t resp_len = 0;
printf("Product ID isteği gönderiliyor...\r\n");
BNO086_SendPacket(CHANNEL_COMMAND, payload, 1);
HAL_Delay(50);
if (BNO086_ReceivePacket(response, &resp_len))
{
printf("Product ID cevabı (%d byte): ", resp_len);
for (int i = 0; i < resp_len; i++)
printf("0x%02X ", response[i]);
printf("\r\n");
}
else
{
printf("Cevap alınamadı!\r\n");
}
}
void BNO086_Init(void)
{
HAL_Delay(300); // Açılışta bekle
if (HAL_I2C_IsDeviceReady(&hi2c2, BNO086_I2C_ADDR, 2, 100) != HAL_OK)
{
printf("BNO086 hazır değil!\r\n");
return;
}
printf("BNO086 hazır, Product ID okunuyor...\r\n");
BNO086_TestProductID();
}
2025-07-08 6:35 AM - edited 2025-07-08 6:41 AM
You forgot to attach your schematic.
@CANZT-FD wrote:I connected the SDA and SCL lines to a logic analyzer, but there's no activity at all.
Have you also used an analogue oscilloscope - to see what's happening in the analogue domain?
Do you have proper pull-ups?
The sensor also supports SPI & UART - have you tried either/both of them?
via: https://www.ceva-ip.com/product/bno-9-axis-imu/
Have you contacted the manufacturer for support?
https://www.ceva-ip.com/contact-us/
PS:
Re-reading:
@CANZT-FD wrote:I had previously used the BNO055 sensor successfully
So look carefully at what's different between what you did then, and what you have now for the BNO086
If you're seeing no activity at all on the I2C lines, that must be a basic setup issue in your STM32 - no I2C slave is going to work in that situation!
2025-07-08 6:38 AM
I have added the schematic in this way.
My design was created for I2C communication.
Actually, I originally designed it for the BNO055.
I removed the BNO055 and soldered the BNO086 in its place.
As a difference, I left pin 17 unconnected to prevent the sensor from operating in SPI mode.
Is there anything else I need to do?
2025-07-08 6:55 AM
Please show a complete schematic.
The net name "+3v3-NPN" sounds suspicious - what's going on there?
What are the pullup values?
Have you also used an analogue oscilloscope - to see what's happening in the analogue domain?
The sensor also supports SPI & UART - have you tried either/both of them?
Have you contacted the manufacturer for support?
@CANZT-FD wrote:I removed the BNO055 and soldered the BNO086 in its place
So have you checked carefully for any damage in that process; shorts; poor joints; etc ... ?
Are they supposed to be "drop-in" replacements?
@CANZT-FD wrote:As a difference, I left pin 17 unconnected to prevent the sensor from operating in SPI mode.
Was that not also required for the BNO055 ?
Suggests not just a drop-in replacement?
If you're seeing no activity at all on the I2C lines, that must be a basic setup issue in your STM32 - no I2C slave is going to work in that situation!
2025-07-08 10:58 PM
Thank you for your response.
I’ve attached the schematic for the 3.3V NPN configuration.
When I check with a multimeter, I can see the 3.3V sensor supply voltage.
My current design does not support SPI or UART, so I’m unable to change the hardware layout.
I am required to use I2C.
The pull-up resistors are 10kΩ (I also tested with 2.2kΩ, but it didn’t work).
I soldered the sensor chip and checked for shorts or other issues, but I couldn’t find any problems.
There doesn’t seem to be an issue with the STM32, because when I run other I2C code, I can observe activity on the SDA and SCL lines.
However, when I run the BNO086-specific code (such as the one above), I don’t see any signal at all on the lines.
I’m beginning to doubt whether I’ve written the code correctly.
I’m not sure if the issue is due to the BNO086 using the SH-2 protocol.
The image I previously mentioned was taken from the BNO086 datasheet—my apologies for the incorrect information.
Pin 18 is defined as the SPI\_SELECT pin. I have left pin 18 unconnected.
This is the current situation: I am unable to get any response from the sensor, and I can’t determine whether the issue is hardware- or software-related.
2025-07-09 11:11 PM - last edited on 2025-07-10 2:55 AM by Andrew Neil
Merged with original thread.
I opened this thread as a continuation of the discussion here:
https://community.st.com/t5/others-stm32-mcus-related/i-couldn-t-get-my-bno086-to-work/m-p/820144/thread-id/7443
I’ve attached logic analyzer captures showing what I observed on the SDA and SCL lines.
yellow=SCL
blue=SDA
mcu=stm32u5
SDA SCL resistor 10kohm
2025-07-10 2:10 AM - edited 2025-07-10 2:10 AM
Hello,
Why opening a new thread with the same subject (I presume) if the previous one was not solved?
2025-07-10 2:41 AM
You're right, but I opened a new thread because I had new analysis data and wanted to make it more noticeable.
2025-07-10 3:01 AM
Please don't do that - it confuses the issue by spreading the necessary information over multiple threads!
You still haven't shown the full schematic, nor given the full part number of the STM32.
Have you looked at the I2C lines with an oscilloscope?
You said originally that there was "no activity at all" on the I2C lines; now you're showing that there is activity - so what's changed?
How does what your logic analyser shows compare to what the sensor datasheet specifies?
How does what your logic analyser shows compare to what you were getting with the other sensor ?