0
\$\begingroup\$

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.

\$\endgroup\$
11
  • \$\begingroup\$ You didn't include your actual circuit or full code. It is quite difficult to guess at the all the possible problems with such minimal information. Did you try the original setup and code example on the All info page (single page) Adafruit site: learn.adafruit.com/… \$\endgroup\$ Commented Mar 11, 2023 at 8:37
  • \$\begingroup\$ Yes I tried but it didn't work. Right now i just want to see its sensor ready and that's my code for it. \$\endgroup\$ Commented Mar 11, 2023 at 8:46
  • \$\begingroup\$ If seems you're doing your own I2C setups, are you sure you set the correct address for the module? (0x28, 0x29). I see two address setups in your code but no idea what they are. There is an Adafruit customer support forum - you might try asking there for more direct info. See: forums.adafruit.com \$\endgroup\$ Commented Mar 11, 2023 at 9:09
  • \$\begingroup\$ Adress about adr pin vcc or gnd. I already posted there \$\endgroup\$ Commented Mar 11, 2023 at 9:34
  • \$\begingroup\$ @LOODAN - Did you try the Bosch-Library? (github.com/BoschSensortec/BNO055_driver) \$\endgroup\$ Commented Mar 11, 2023 at 14:31

1 Answer 1

1
\$\begingroup\$

You are trying to use the bus in MSPinit function. That function is called by I2Cinit to initialize the IO subsystem before initializing the I2C peripheral. So you did not bother to check what the error code returned from the function was, other than it's not OK.

Likely it still does not work because is that the chip looks like it will not respond to protocol used by IsDeviceReady.

The data sheet of the chip does not indicate that you can do a read without writing a register value first.

After initializing the IO pins and I2C properly, try reading the Device ID register instead. If that succeeds, chip works on the bus. If it doesn't, then the problem is elsewhere.

\$\endgroup\$
1
  • \$\begingroup\$ Thank you for answer ,first i read device ıd but not success \$\endgroup\$ Commented Mar 12, 2023 at 7:18

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.