Skip to content

Repository files navigation

# 🎯 BNO055 Orientation HUD for Adafruit QT Py ESP32-C3

A robust, lightweight C++ firmware designed for tracking 9-DOF orientation using the Bosch **BNO055** IMU and an **Adafruit QT Py ESP32-C3** microcontroller. Built with PlatformIO, this project features an interactive ASCII HUD directly in the serial terminal, complete with visual axis bars, dynamic FPS calculations, and real-time sensor calibration diagnostics.

---

## 📸 Console HUD Interface

```text
 ░▒▓████████████████████████████████████████████████████████▓▒░
 ░▒▓█      BNO055 ORIENTATION HUD - ESP32-C3 QT Py     █▓▒░
 ░▒▓████████████████████████████████████████████████████████▓▒░
  ├── Hardware Subsystem : Adafruit QT Py ESP32-C3
  ├── Protocol Interface : I2C Bus (Fast Mode 100kHz)
  └── Target Address     : 0x28 (Default Mode)
 ──────────────────────────────────────────────────────────────
  [SYSTEM INIT] Connecting to BNO055... [  OK - ONLINE  ]
 ──────────────────────────────────────────────────────────────

  YAW (Z: 0..360°)     PITCH (Y: ±180°)     ROLL (X: ±90°)       FPS   STATUS
 ══════════════════════════════════════════════════════════════════════════════════
   180.2° [───┼──◆───]     -12.4° [────◆────]       2.1° [────┼─◆──]    24.5 CALIB: SYS:3 G:3 A:3 M:3 [  FULL  ]
   182.5° [───┼──◆───]     -12.1° [────◆────]      15.4° [────┼──◆─]    24.8 CALIB: SYS:3 G:3 A:3 M:3 [  FULL  ]
   185.0° [───┼───◆──]     -11.8° [────◆────]     -45.0° [──◆─┼────]    25.0 CALIB: SYS:2 G:3 A:3 M:1 [ MID-CAL ]

⚡ Core Features

  • Real-time 9-DOF Orientation Tracking: Outputs Euler angles ($Yaw$, $Pitch$, $Roll$) using hardware sensor fusion.
  • Interactive Terminal HUD: Visual slider bars ([───┼──◆───]) map rotation dynamics intuitively in text mode.
  • Diagnostics & Health Metrics: Tracks system, gyroscope, accelerometer, and magnetometer calibration levels ($0-3$).
  • Performance Telemetry: Built-in real-time frame rate (FPS) counter.
  • Plug-and-Play I2C Support: Compatible with default Adafruit QT Py ESP32-C3 STEMMA QT / QWIIC pinout.

🧩 Hardware & Wiring Setup

Connect the BNO055 sensor module to the Adafruit QT Py ESP32-C3 using either STEMMA QT or manual solder connections:

BNO055 Pin QT Py ESP32-C3 Pin Notes
VCC 3V3 Power supply (3.3V)
GND GND Ground reference
SDA SDA (GPIO 5) I2C Data line
SCL SCL (GPIO 6) I2C Clock line
COM3 / I2C GND Required to force I2C communication mode

🔄 Algorithm & Signal Flow

The firmware operates on an asynchronous event-driven loop. The execution pipeline follows this structured algorithm:

                  ┌──────────────────────────────────┐
                  │          System Power-On         │
                  └────────────────▓─────────────────┘
                                   │
                                   ▼
                  ┌──────────────────────────────────┐
                  │ 1. USB CDC & Serial Init (115200)│
                  └────────────────▓─────────────────┘
                                   │
                                   ▼
                  ┌──────────────────────────────────┐
                  │ 2. Hardware I2C Bus Init (100kHz)│
                  └────────────────▓─────────────────┘
                                   │
                                   ▼
                  ┌──────────────────────────────────┐
                  │ 3. BNO055 Detection (Address 0x28)│
                  └────────┬─────────────────┬───────┘
                           │                 │
                  SUCCESS  │                 │ FAIL
                           ▼                 ▼
          ┌──────────────────────────┐  ┌──────────────────────────┐
          │  Configure NDOF Fusion   │  │ Output Error to Console  │
          │  & Disable Ext Crystal   │  │    & Halt Execution      │
          └────────────▓─────────────┘  └──────────────────────────┘
                       │
                       ▼
          ┌──────────────────────────┐
          │  Render HUD Title Banner │
          └────────────▓─────────────┘
                       │
                       ▼
     ┌─────────────────────────────────────────────────────┐
     │                Main Loop Execution (~25 Hz)         │
     ├─────────────────────────────────────────────────────┤
     │ A. Measure elapsed time & update FPS counter.       │
     │ B. Fetch Euler orientation vector from BNO055 API.  │
     │ C. Read 4-bit calibration status (SYS, G, A, M).   │
     │ D. Normalize angles into visual ASCII slider bars.  │
     │ E. Format and stream telemetry frame over USB-CDC.  │
     │ F. Execute non-blocking delay (40 ms).             │
     └──────────────────────────▓──────────────────────────┘
                                │
                                └─── Loop Continues (Repeat) ───►


🛠️ Project Configuration (platformio.ini)

Ensure your platformio.ini is configured as follows for proper USB CDC handling on ESP32-C3:

[env:adafruit_qtpy_esp32c3]
platform = espressif32
board = adafruit_qtpy_esp32c3
framework = arduino

monitor_speed = 115200

build_flags = 
    -D ARDUINO_USB_CDC_ON_BOOT=1
    -D ARDUINO_USB_MODE=1

monitor_dtr = 1
monitor_rts = 1

lib_deps = 
    wire
    adafruit/Adafruit BNO055 @ ^1.6.4
    adafruit/Adafruit Unified Sensor @ ^1.1.15

🚀 Getting Started

  1. Clone this repository to your local computer:
git clone [https://github.com/YourUsername/bno055-esp32c3-hud.git](https://github.com/YourUsername/bno055-esp32c3-hud.git)
  1. Open the project folder in Visual Studio Code with the PlatformIO extension installed.
  2. Connect your Adafruit QT Py ESP32-C3 via a USB-C cable.
  3. Build and upload the firmware:
  • Build: Ctrl + Alt + B
  • Upload: Ctrl + Alt + U
  1. Open the Serial Monitor at 115200 baud to view the live orientation HUD.

🧪 Testing & Verification

This project has been fully compiled, flashed, and hardware-tested using PlatformIO (VS Code extension with Espressif 32 platform version 6.x+).

Tested Environment:

  • IDE / Environment: Visual Studio Code + PlatformIO IDE
  • Core Platform: Espressif 32 (espressif32 @ 6.x)
  • Framework: Arduino ESP32 Framework
  • Target Hardware: Adafruit QT Py ESP32-C3
  • Sensors: Bosch BNO055 Absolute Orientation Sensor (0x28)
  • Status: PASS (0 compilation errors, 0 runtime memory leaks)
========================= [SUCCESS] Took 4.12 seconds =========================
Environment           Status    Duration
--------------------  --------  ------------
adafruit_qtpy_esp32c3 SUCCESS   00:00:04.120
========================= 1 succeeded in 00:00:04.120 =========================

## 📜 License

Distributed under the **MIT License**. Free for educational, personal, and commercial use.

About

An ESP32-based absolute location tracking system combining GPS and IMU sensor fusion to provide accurate position, orientation, and motion data for robotics, navigation, and wearable applications.

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages