SPI for IMU BNO086

Hi, im trying to use SPI to get data from the imu bno086, however it’s not working.

I use the XIAO ESP32S3.

Breakout board I bought: SparkFun VR IMU Breakout - BNO086 (Qwiic) - SparkFun Electronics
Instruction I followed: Hardware Hookup - SparkFun VR IMU Breakout - BNO086 (Qwiic) Hookup Guide

My wire:

3.3V 3.3V
GND GND
D5 CS
MISO/PICO SI
MOSI/POCI SO
SCK (D18) SCK
A0 INT
A1 RST

Could anyone help me?

Double-check the wiring, the table says MISO/PICO but it should be MISO/POCI, make sure those aren’t swapped

For SPI you’ll also need to solder the PS0 & PS1 jumper pads Hardware Hookup - SparkFun VR IMU Breakout - BNO086 (Qwiic) Hookup Guide (put solder blobs on each of the 2 circled pad areas)

yes I did put solder blobs on each of the 2 circled pad areas. I also tried to switch around the miso/mosi wire but it still didnt work.

It also looks like A0 & A1 might not be right for Reset and INT, try D4 & D5 instead?

I tried it and it’s not the case.

My connection:
D7 → CS (purple)
MOSI → SI (green)
MISO → SO (brown)
SCK → SCK (yellow)
A4 → INT (red)
A5 → RST (white)
3V3 → 3V3 (red)
GND → GND (black)

OK, I see quite a bit of flux on both boards’ pin areas…try cleaning that with IPA and re-try

I don’t have much advice other than what Seeed documents here for the spi on that board Pin Multiplexing with Seeed Studio XIAO ESP32S3 (Sense) | Seeed Studio Wiki - do you happen to have a different MCU if the above IPA clean doesn’t work?

can you share the sketch ? maybe there is something

I cleaned the boards with ISO, but it seems not to have any changes.

For the code, I got it from “SparkFun BNO08x Cortex Based IMU” on Arduino IDE. There is an example using SPI for IMU by go to: File → Examples -->Sparkfun → SPI → Examples_01

  Using the BNO08x IMU

  This example shows how to communicate with the sensor over SPI.

  It requires a few more connections than the qwiic cable.
  In addition to your usual SPI lines (CS/PICO/POCI/SCK),
  This also requires INT and RST. These are crucial for timing when talking to
  this sensor.

  It outputs the i/j/k/real parts of the rotation vector.
  https://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation

  By: Nathan Seidle
  SparkFun Electronics
  Date: December 21st, 2017
  SparkFun code, firmware, and software is released under the MIT License.
	Please see LICENSE.md for further details.

  Originally written by Nathan Seidle @ SparkFun Electronics, December 28th, 2017

  Adjusted by Pete Lewis @ SparkFun Electronics, June 2023 to incorporate the
  CEVA Sensor Hub Driver, found here:
  https://github.com/ceva-dsp/sh2

  Also, utilizing code from the Adafruit BNO08x Arduino Library by Bryan Siepert
  for Adafruit Industries. Found here:
  https://github.com/adafruit/Adafruit_BNO08x

  Also, utilizing I2C and SPI read/write functions and code from the Adafruit
  BusIO library found here:
  https://github.com/adafruit/Adafruit_BusIO

  Hardware Connections:
  IoT RedBoard --> BNO08x
  D5  --> CS
  PICO --> SI
  POCI --> SO
  SCK  --> SCK
  A4  --> INT
  A5  --> RST
  3V3  --> 3V3
  GND  --> GND

  BNO08x "mode" pins set for SPI:
  PSO --> 3V3
  PS1 --> 3V3

  Serial.print it out at 115200 baud to serial monitor.

  Feel like supporting our work? Buy a board from SparkFun!
  https://www.sparkfun.com/products/22857
*/

//#include <Wire.h>

#include "SparkFun_BNO08x_Arduino_Library.h"  // CTRL+Click here to get the library: http://librarymanager/All#SparkFun_BNO08x
BNO08x myIMU;

// For SPI, we need some extra pins defined:
// Note, these can be other GPIO if you like.
#define BNO08X_CS   7
#define BNO08X_INT  A4
#define BNO08X_RST  A5

// If using the MicroMod Machine Learning Carrier Board, use these pins:
// for more info see https://github.com/sparkfun/SparkFun_BNO08x_Arduino_Library/issues/19
//#define BNO08X_CS   PWM0
//#define BNO08X_INT  D0 // Note, D0 is also the CS pin for the camera, so you'll need to change that if you're using both.
// a good alternative for D0 is PWM1, (A0 and A1 are only inputs on the carrier board).
//#define BNO08X_RST  D1

void setup() {
  Serial.begin(115200);
  
  while(!Serial) delay(10); // Wait for Serial to become available.
  // Necessary for boards with native USB (like the SAMD51 Thing+).
  // For a final version of a project that does not need serial debug (or a USB cable plugged in),
  // Comment out this while loop, or it will prevent the remaining code from running.
  
  Serial.println();
  Serial.println("BNO08x Read Example");

  if (myIMU.beginSPI(BNO08X_CS, BNO08X_INT, BNO08X_RST) == false) {
    Serial.println("BNO08x not detected. Check your jumpers and the hookup guide. Freezing...");
    while (1)
      ;
  }
  Serial.println("BNO08x found!");

  setReports();

  Serial.println("Reading events");
  delay(100);
}

// Here is where you define the sensor outputs you want to receive
void setReports(void) {
  Serial.println("Setting desired reports");
  if (myIMU.enableRotationVector() == true) {
    Serial.println(F("Rotation vector enabled"));
    Serial.println(F("Output in form i, j, k, real, accuracy"));
  } else {
    Serial.println("Could not enable rotation vector");
  }
  delay(100); // This delay allows enough time for the BNO086 to accept the new 
              // configuration and clear its reset status
}

void loop() {
  delay(10);

  if (myIMU.wasReset()) {
    Serial.print("sensor was reset ");
    setReports();
  }

  // Has a new event come in on the Sensor Hub Bus?
  if (myIMU.getSensorEvent() == true) {

    // is it the correct sensor data we want?
    if (myIMU.getSensorEventID() == SENSOR_REPORTID_ROTATION_VECTOR) {

      float quatI = myIMU.getQuatI();
      float quatJ = myIMU.getQuatJ();
      float quatK = myIMU.getQuatK();
      float quatReal = myIMU.getQuatReal();
      float quatRadianAccuracy = myIMU.getQuatRadianAccuracy();

      Serial.print(quatI, 2);
      Serial.print(F(","));
      Serial.print(quatJ, 2);
      Serial.print(F(","));
      Serial.print(quatK, 2);
      Serial.print(F(","));
      Serial.print(quatReal, 2);
      Serial.print(F(","));
      Serial.print(quatRadianAccuracy, 2);

      Serial.println();
    }
  }
}

I tried to collect data using I2C (with the XIAO ESP32S3 board) and it worked perfectly fine. I don’t think the board would be the main issue, but I will test with different ESP board to make sure.

On line 61 in your sketch, for BNO08X_CS instead of 7, try to use D7. D7 on a XIAO is connected to IO44, not GPIO 7.

Yess it works now. Ty

Cool, thanks for sharing back