I couldn't get my bno086 to work
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();
}
