Source: https://mokxi.com/libraries/adafruit-bno055
Updated: 2026-11-22

Libraries / Sensors

Arduino library · Sensors

# Adafruit BNO055: absolute orientation from a nine-axis sensor

Yes, you can build with the Adafruit BNO055 library online in Mokxi with nothing to install. Its hardware is not simulated, so a sketch says plainly that it cannot reach the device. The example below, "Orientation from a BNO055 (sensorapi)", runs on the Arduino Uno R3.

Run the example in Mokxi See the calls

Built in on Mokxi: #include <Adafruit_BNO055.h> and it builds, with nothing to install. Free, and no account needed.

## What Adafruit BNO055 does

The Bosch BNO055 is an accelerometer, gyroscope and magnetometer with its own processor that fuses the three. Where an MPU6050 hands you raw motion and leaves the math to your sketch, the BNO055 reports finished orientation: heading, roll and pitch in degrees, or a quaternion, plus gravity and linear acceleration separated for you. The Adafruit library reads all of it over I2C at 0x28 (or 0x29 with ADR high).

The chip calibrates itself as it moves. getCalibration() gives a 0 to 3 level for the system, gyroscope, accelerometer and magnetometer, and the heading is only trustworthy once the magnetometer reaches 3, usually after waving the sensor in a figure eight. Once calibrated, getSensorOffsets() lets you save the offsets and setSensorOffsets() restores them at the next start, so you skip the dance.

Mokxi has no BNO055 part yet, so the library compiles but finds nothing to talk to. As on real hardware with nothing wired, begin() polls address 0x28 for 850 ms and returns false, and the example prints its "no BNO055 detected" line and stops; any reading would be 0. Use it to check a sketch builds before uploading. Upstream sketches also include utility/imumaths.h, which does not resolve in Mokxi; Adafruit_BNO055.h already brings the imu:: types, so delete that line.

Library Manager name | Adafruit BNO055

Author | Adafruit

Include | #include <Adafruit_BNO055.h>

Boards | every board Mokxi compiles for but ATtiny85

In the simulator | Builds and runs, and says plainly that the hardware behind it is not simulated.

## Install it

It builds on every board Mokxi compiles for but ATtiny85.

In Mokxi it is built in: #include <Adafruit_BNO055.h> and the sketch compiles, with no download, no zip and no Library Manager.

On a real board, install "Adafruit BNO055" by Adafruit from the Arduino IDE’s Library Manager (Sketch, Include Library, Manage Libraries), or add Adafruit BNO055 to lib_deps in PlatformIO. Mokxi follows the calls of release 1.6.4, so a sketch written here builds there too.

What to know in the simulator: Mokxi has no BNO055 part yet: begin() polls 0x28 for 850 ms as upstream does and returns false, and readings are 0. Upstream sketches also include utility/imumaths.h, which does not resolve here (firmware/lib/utility is the C++ <utility> header); Adafruit_BNO055.h already brings the imu:: types, so leave that line out.

- ESP32-C3
- Arduino Uno
- Arduino Nano
- Arduino Mega 2560
- Arduino Leonardo
- SparkFun Pro Micro
- Arduino Micro
- ESP32-C6
- WCH CH32V003
- Raspberry Pi Pico
- Raspberry Pi Pico W
- Seeed XIAO SAMD21
- STM32
- STM32 Nucleo-F411RE
- STM32 Blue Pill
- micro:bit V2
- Arduino Uno R4
- ESP32 DevKit
- ESP32-S3-DevKitC-1
- ESP8266 NodeMCU
- Arduino Pro Mini 3.3 V
- Seeed XIAO ESP32-C3
- ESP32-C3 SuperMini
- Seeed XIAO ESP32-C6
- ESP32-DevKitC V4
- LOLIN32 Lite
- Wemos D1 R32
- Cheap Yellow Display
- TTGO T-Display
- Seeed XIAO ESP32-S3
- ESP32-S3-CAM
- Arduino Nano ESP32
- Arduino Nano RP2040 Connect
- Seeed XIAO RP2040
- Waveshare RP2040-Zero
- Arduino Uno R4 WiFi

## The calls you will use

In the order a sketch meets them.

### Adafruit_BNO055 bno = Adafruit_BNO055(55, 0x28, &Wire)

The sensor with an ID of your choosing (55 in the examples), its I2C address and the bus.

### bno.begin()

Finds the chip and starts it in NDOF fusion mode. Returns false if nothing answers.

### bno.setExtCrystalUse(true)

Uses the breakout’s 32 kHz crystal for steadier timing. Call it after begin() on boards that have one.

### bno.getEvent(&event)

Fills a sensors_event_t with orientation in degrees: event.orientation.x is heading, y roll and z pitch.

### imu::Vector<3> euler = bno.getVector(Adafruit_BNO055::VECTOR_EULER)

One of the chip’s vectors: VECTOR_EULER, VECTOR_ACCELEROMETER, VECTOR_GYROSCOPE, VECTOR_MAGNETOMETER, VECTOR_LINEARACCEL or VECTOR_GRAVITY.

### imu::Quaternion quat = bno.getQuat()

Orientation as a quaternion, which avoids the gimbal lock Euler angles hit near 90 degrees of pitch.

### bno.getCalibration(&system, &gyro, &accel, &mag)

Calibration levels from 0 (none) to 3 (full) for the fused system and each sensor.

### bno.getSensorOffsets(calibData)

Copies the calibration offsets out once isFullyCalibrated() is true, to save in EEPROM.

## Example: Orientation from a BNO055 (sensorapi)

On the Arduino Uno R3. It runs in the browser exactly as printed.

sketch.ino · Arduino Uno R3

Open it in the editor, wired and ready to run

## Common errors and how to fix them

### Ooops, no BNO055 detected ... Check your wiring or I2C ADDR!

begin() got no answer. Check SDA and SCL, power, and the address: 0x28 with ADR low, 0x29 with it high. In Mokxi this is always the result, since there is no BNO055 part yet.

### utility/imumaths.h: No such file or directory

Mokxi resolves utility as the C++ standard header, so that include fails here. Remove the line; Adafruit_BNO055.h already provides imu::Vector and imu::Quaternion.

### Heading drifts or jumps by tens of degrees

The magnetometer is not calibrated, or a motor, speaker or steel nearby bends the field. Wait for getCalibration() to show 3 for the magnetometer and mount the sensor away from magnets.

## Questions and answers

### BNO055 or MPU6050?

The MPU6050 is cheaper and gives raw motion; you fuse it yourself, for example with Madgwick. The BNO055 does the fusion on chip and adds a magnetometer for a true heading.

## Keep going

### Learn

- Arduino MPU6050: Accelerometer and Tilt
- I2C Scanner for Arduino and ESP32, and Fixes

### More sensors libraries

- DHT sensor library
- DHT20
- VL53L0X
- Adafruit_VL53L0X
- HX711 Arduino Library
- MPU6050
- Adafruit MPU6050
- BME280
- GY521
- SparkFun GridEYE AMG88 Library
- Adafruit BMP3XX Library
- Sensirion I2C SGP30
- ld2410
- Nova Fitness Sds dust sensors library

Every built-in library · Open the editor

## Try Adafruit BNO055 without installing anything

Open the example, change the sketch, and keep your version in a free account.

Start building free

Open the editor
