My sensor is a BNO055 Absolute Orientation Sensor.
I wanted to see if the sensor is ready or not. I tried to run it using different libraries, but it never worked. I couldn't understand why. Then I wanted to test if the sensor was ready with the I2C protocol. At this point in my work, I saw that my sensor never came to the ready state.
Connections:
SDA_pin -> SDA pin sensor
SCL_pin -> SCL pin sensor
5V -> VCC
GND -> GND
ADR -> GND
PS0 -> GND
PS1 -> GND
I use I2C with my STM32F401RE.
------MX_I2C3_Init()----------- hi2c3.Instance = I2C3; hi2c3.Init.ClockSpeed = 100000; hi2c3.Init.DutyCycle = I2C_DUTYCYCLE_2; hi2c3.Init.OwnAddress1 = 0; hi2c3.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT; hi2c3.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE; hi2c3.Init.OwnAddress2 = 0; hi2c3.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE; hi2c3.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE; ---------------------------- void HAL_I2C_MspInit(I2C_HandleTypeDef* hi2c) { GPIO_InitTypeDef GPIO_InitStruct = {0}; if (hi2c->Instance == I2C3) { __HAL_RCC_GPIOC_CLK_ENABLE(); __HAL_RCC_GPIOA_CLK_ENABLE(); /* I2C3 GPIO Configuration PC9 ------> I2C3_SDA PA8 ------> I2C3_SCL */ GPIO_InitStruct.Pin = GPIO_PIN_9; GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Alternate = GPIO_AF4_I2C3; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); GPIO_InitStruct.Pin = GPIO_PIN_8; GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Alternate = GPIO_AF4_I2C3; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /* Peripheral clock enable */ __HAL_RCC_I2C3_CLK_ENABLE(); } while (!ready) { if (HAL_I2C_IsDeviceReady(&hi2c3, (0x28 << 1), 10, 1000) == HAL_OK) { // BNO055 is ready, perform additional initialization ready = 1; } else if (HAL_I2C_IsDeviceReady(&hi2c3 ,(0x29 << 1), 10, 1000) == HAL_OK) { ready = 2; } else { // BNO055 is not ready yet, wait and try again HAL_Delay(100); } It never goes into HAL_OK state. I tried with the ADR pin connected to VCC or GND, but nothing changes.
----EDİT----
Tried I2C scan but not work.(for find divice address) I2C_Scan
I performed an I2C scan on a different sensor mpu6050 using the same pins and it was successful. I don't think it's an issue with my mcu.