Hardware Setup

The hardware setup for the UART-RVC mode should probably be called easyware because of how simple it is. Three wires and a solder jumper (or and additional jumper wire) and you're off to the autonomous vacuum cleaner races.

UART-RVC Wiring

To allow your device to listen to the heading and acceleration data being output by the BNO085 requires just a few connections. It's similar to the connections for the UART mode, but because there is no software configuration of the BNO085 required, you only need to connect your device's RX pin and pull the P0 pin high. The TX pin on your device can be left unattached

Here we show the Wiring for a  Feather M4 for CircuitPython, and a Raspberry Pi for Python:

Feather Wiring

  • Feather 3V to BNO085 Vin (Red Wire). 
  • Device GND to BNO085 GND (Black Wire)
  • Device RX to BNO085 SDA (Blue Wire)
  • Feather 3V to BNO085 P0 (Purple Wire). 

 

Raspberry Pi Wiring

  • RPi 3V to BNO085 Vin (Red Wire). 
  • RPi GND to BNO085 GND (Black Wire)
  • RPi RX to BNO085 SDA (Blue Wire)
  • RPi 3V to BNO085 P0 (Purple Wire)
For an even simpler hardware setup, bridge the P0 solder jumper on the back of the board to keep it configured in UART-RVC mode. You can always remove the solder to use other modes!

CircuitPython Installation of BNO08x_RVC Library

You'll need to install the Adafruit CircuitPython BNO08x RVC library on your CircuitPython board.

Follow the instructions on the Python & CircuitPython page for installing CircuitPython and downloading the library bundle

Before continuing make sure your board's lib folder or root filesystem has the adafruit_BNO08x_RVC.mpy file copied over.

 

Python Installation of BNO08x RVC Library

Follow the instructions on the Python & CircuitPython page to set up your Raspberry Pi or other SBC and once that's done, from your command line run the following command:

  • sudo pip3 install adafruit-circuitpython-bno08x-rvc

If your default Python is version 3 you may need to run 'pip' instead. Just make sure you aren't trying to use CircuitPython on Python 2.x, it isn't supported!

CircuitPython & Python Usage

he following code will walk you through a basic test of the UART RVC mode in the Python REPL

To demonstrate the usage of the sensor setup a UART connection and then we'll initialize the sensor and read the heading and acceleration information from within the board's REPL.

For CircuitPython connect to the board's serial REPL so you are at the CircuitPython >>> prompt. For Python, just type `python` or `python3` to enter the REPL

UART Initialization - CircuitPython

If you are using the UART connection with a board (like a Feather) running CircuitPython, create your uart object as follows:

Download: file
import board
import busio
from adafruit_bno08x_rvc import BNO08x_RVC

uart = busio.UART(board.TX, board.RX, baudrate=115200, receiver_buffer_size=2048)

UART Initialization - Python

Check how you specific board supports UART and where the port entry is created and named. For the Raspberry Pi, this is done using the pyserial module and the UART used is /dev/serial0. Then you create your sensor object as follows:

Download: file
import serial
uart = serial.Serial("/dev/serial0", 115200)

BNO08x_RVC creation and usage

Now you're ready to create a BNO8x_RVC instance with your UART object and use it to read the heading and acceleration value using the heading property:

Download: file
from adafruit_bno08x_rvc import BNO08x_RVC
rvc = BNO08x_RVC(uart)

yaw, pitch, roll, x_accel, y_accel, z_accel = rvc.heading
print("Yaw: %2.2f Pitch: %2.2f Roll: %2.2f Degrees" % (yaw, pitch, roll))
print("Acceleration X: %2.2f Y: %2.2f Z: %2.2f m/s^2" % (x_accel, y_accel, z_accel))

Example Code

# SPDX-FileCopyrightText: 2020 Bryan Siepert, written for Adafruit Industries
#
# SPDX-License-Identifier: Unlicense
import time
import board
import busio

uart = busio.UART(board.TX, board.RX, baudrate=115200, receiver_buffer_size=2048)

# uncomment and comment out the above for use with Raspberry Pi
# import serial
# uart = serial.Serial("/dev/serial0", 115200)

# for a USB Serial cable:
# import serial
# uart = serial.Serial("/dev/ttyUSB0", baudrate=115200)

from adafruit_bno08x_rvc import BNO08x_RVC  # pylint:disable=wrong-import-position

rvc = BNO08x_RVC(uart)

while True:
    yaw, pitch, roll, x_accel, y_accel, z_accel = rvc.heading
    print("Yaw: %2.2f Pitch: %2.2f Roll: %2.2f Degrees" % (yaw, pitch, roll))
    print("Acceleration X: %2.2f Y: %2.2f Z: %2.2f m/s^2" % (x_accel, y_accel, z_accel))
    print("")
    time.sleep(0.1)

This guide was first published on Oct 14, 2020. It was last updated on Oct 14, 2020.

This page (UART-RVC for Python & CircuitPython) was last updated on Nov 06, 2020.