BNO08X Sensor not detected - ESP32

Hey!

So I got the BNO08X Sensor for a vr project, and did I2C connections on this sensor to run a QuaternionYawPitchRoll example provided by Adafruit. However, I am not able to retrieve data as it says "I2C address not found" along with "Failed to find BNO08X chip".
Clearly, I know I am doing something wrong, but I am not able to figure it out. Can someone help me?

Here are some details:

  1. I am using an ESP-32-s3 wroom 1
  2. I've used the connected like this
    VIN>>3.3V
    GND>>GND
    SDA>>GPIO8
    SCL>>GPIO9
    PS0>>GND
    PS1>>GND
  3. I am using Adafruit_BNO08x Library

Here is the code that I am using:

// Basic demo for readings from Adafruit BNO08x
#include <Wire.h>
#include <Adafruit_BNO08x.h>

// Define I2C pins for ESP32-S3
#define SDA_PIN 8
#define SCL_PIN 9

// Create BNO08x instance
Adafruit_BNO08x bno08x;

sh2_SensorValue_t sensorValue;

void setup() {
  Serial.begin(115200);
  while (!Serial);

  Serial.println("Adafruit BNO08x test!");

  // Initialize I2C with specified SDA and SCL pins
  Wire.begin(SDA_PIN, SCL_PIN);

  // Try to initialize the BNO08x sensor
  if (!bno08x.begin_I2C(0x4A, &Wire)) { // Try 0x4B if 0x4A doesn't work
    Serial.println("Failed to find BNO08x chip");
    while (1) {
      delay(10);
    }
  }

  Serial.println("BNO08x Found!");

  for (int n = 0; n < bno08x.prodIds.numEntries; n++) {
    Serial.print("Part ");
    Serial.print(bno08x.prodIds.entry[n].swPartNumber);
    Serial.print(": Version ");
    Serial.print(bno08x.prodIds.entry[n].swVersionMajor);
    Serial.print(".");
    Serial.print(bno08x.prodIds.entry[n].swVersionMinor);
    Serial.print(".");
    Serial.print(bno08x.prodIds.entry[n].swVersionPatch);
    Serial.print(" Build ");
    Serial.println(bno08x.prodIds.entry[n].swBuildNumber);
  }

  setReports();

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

// Define sensor outputs to receive
void setReports() {
  Serial.println("Setting desired reports");
  if (!bno08x.enableReport(SH2_GAME_ROTATION_VECTOR)) {
    Serial.println("Could not enable game rotation vector");
  }
}

void loop() {
  delay(10);

  if (bno08x.wasReset()) {
    Serial.print("Sensor was reset ");
    setReports();
  }

  if (!bno08x.getSensorEvent(&sensorValue)) {
    return;
  }

  switch (sensorValue.sensorId) {
    case SH2_GAME_ROTATION_VECTOR:
      Serial.print("Game Rotation Vector - r: ");
      Serial.print(sensorValue.un.gameRotationVector.real);
      Serial.print(" i: ");
      Serial.print(sensorValue.un.gameRotationVector.i);
      Serial.print(" j: ");
      Serial.print(sensorValue.un.gameRotationVector.j);
      Serial.print(" k: ");
      Serial.println(sensorValue.un.gameRotationVector.k);
      break;
  }
}

So did you try with 0x4B?

What I2C addresses (if any) were detected when you ran the I2C scanner sketch?

you mean modifying 0x4A in the .h file right? that i did

I'm sorry I'm not sure what you mean, this is my first ever project , if you're talking about the serial monitor output than it's this :

20:15:54.256 -> ESP-ROM:esp32s3-20210327
20:15:54.301 -> Build:Mar 27 2021
20:15:54.301 -> rst:0x1 (POWERON),boot:0x8 (SPI_FAST_FLASH_BOOT)
20:15:54.301 -> SPIWP:0xee
20:15:54.301 -> mode:DIO, clock div:1
20:15:54.301 -> load:0x3fce2820,len:0x1188
20:15:54.301 -> load:0x403c8700,len:0x4
20:15:54.301 -> load:0x403c8704,len:0xbf0
20:15:54.301 -> load:0x403cb700,len:0x30e4
20:15:54.301 -> entry 0x403c88ac
20:15:54.396 -> Adafruit BNO08x test!
20:15:54.396 -> I2C address not found
20:15:54.396 -> Failed to find BNO08x chip

No, I'm asking about what addresses the I2C Scanner sketch (one of the basic debugging example sketches that is included with the Wire library) produced when you ran it.

Testing your setup with a known good sketch is debugging 101.

No, just on your code.

okay i looked in the WireScan examples and modified it to this :
did i make a mistake or like because it still the same

#include "Wire.h"

#define SDA_PIN 8  // ESP32-S3 SDA
#define SCL_PIN 9  // ESP32-S3 SCL

void setup() {
  Serial.begin(115200);
  while (!Serial);  // Wait for Serial Monitor to open

  Serial.println("\nI2C Scanner");
  Wire.begin(SDA_PIN, SCL_PIN);  // Initialize I2C with custom pins
}

void loop() {
  byte error, address;
  int nDevices = 0;

  Serial.println("Scanning for I2C devices...");
  
  for (address = 1; address < 127; address++) {
    Wire.beginTransmission(address);
    error = Wire.endTransmission();

    if (error == 0) {
      Serial.printf("I2C device found at address 0x%02X\n", address);
      nDevices++;
    } else if (error != 2) {
      Serial.printf("Error %d at address 0x%02X\n", error, address);
    }
  }

  if (nDevices == 0) {
    Serial.println("No I2C devices found");
  }

  Serial.println("\nScan complete. Restarting in 5 seconds...");
  delay(5000);
}

the problem is the same as this QuaternionYawPitchRoll issue for BNO08X Sensor - #6 by shivpat
but i didnt understand how he fixed it

Hi. I have a question regarding your issue. Are you using the purple BNO08X module that I was using in my post. I think I can recall that I had to buy the black adafruit module and I somehow got it to work, but I'll keep you posted if I remember anything. All I know is I modified the .h file and changed the address and it solved my issue.

yeah it's the exact same one, but then again i am using an esp32s3 microcontroller so idk

UPDATE: turns out the problem was in wiring, i was following this


so i connected SDA and SCL to pin 17 and 18. since i needed to connect them to GPIO8 and GPIO9 respectively , but it turns out i should have just simply connect them to pin 8 and 9. its so stupid and it still cost me a whole month.

Are you using the module itself or a development board/device kit?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.