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!