It's easy to use the BNO055 + BMP280 BFF with CircuitPython and the Adafruit_CircuitPython_BNO055 and Adafruit_CircuitPython_BMP280 modules. These modules allow you to easily write Python code to control the BNO055 9-DoF sensor and the BMP280 pressure sensor.
The BNO055 I2C implementation violates the I2C protocol in some circumstances. This causes it not to work well with certain chip families. It does not work well with Espressif ESP32, ESP32-S3, and NXP i.MX RT1011, and it does not work well with I2C multiplexers. Operation with SAMD51, RP2040, STM32F4, and nRF52840 is more reliable.
CircuitPython Microcontroller Wiring
Plug a BNO055 + BMP280 BFF into your QT Py or Xiao form factor board exactly as shown below. Here's an example of connecting a QT Py RP2040 to the BFF.
Connect the QT Py RP2040 with plug headers into the BNO055 + BMP280 BFF with socket headers. They should be plugged in with the backs of the boards facing each other.
For more information on soldering socket headers, check out this Learn Guide.
CircuitPython Usage
To use with CircuitPython, you need to first install the Adafruit_CircuitPython_BNO055 and Adafruit_CircuitPython_BMP280 libraries, and the dependencies, into the lib folder on your CIRCUITPY drive. Then you need to update code.py with the example script.
Thankfully, we can do this in one go. In the example below, click the Download Project Bundle button below to download the necessary libraries and the code.py file in a zip file. Extract the contents of the zip file, and copy the entire lib folder and the code.py file to your CIRCUITPY drive.
Your CIRCUITPY/lib folder should contain the following folders and files:
- adafruit_bus_device/
- adafruit_register/
- adafruit_bmp280.mpy
- adafruit_bno055.mpy
Example Code
Once everything is saved to the CIRCUITPY drive, connect to the serial console to see the data printed out!
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries # SPDX-License-Identifier: MIT # # BNO055 + BMP280 BFF Demo import time import board import adafruit_bno055 import adafruit_bmp280 i2c = board.I2C() # uses board.SCL and board.SDA bno055 = adafruit_bno055.BNO055_I2C(i2c) bmp280 = adafruit_bmp280.Adafruit_BMP280_I2C(i2c) bmp280.sea_level_pressure = 1013.25 while True: print(f"Temperature: {bmp280.temperature:0.1f} C") print(f"Pressure: {bmp280.pressure:0.1f} hPa") print(f"Altitude = {bmp280.altitude:0.2f} meters") print(f"Accelerometer (m/s^2): {bno055.acceleration}") print(f"Magnetometer (microteslas): {bno055.magnetic}") print(f"Gyroscope (rad/sec): {bno055.gyro}") print(f"Euler angle: {bno055.euler}") print(f"Quaternion: {bno055.quaternion}") print(f"Linear acceleration (m/s^2): {bno055.linear_acceleration}") print(f"Gravity (m/s^2): {bno055.gravity}") print() time.sleep(1)
First, both sensors are instantiated over I2C. In the loop, all of the available data parameters from both sensors are printed to the serial monitor every 2 seconds.
Text editor powered by tinymce.