Skip to main content

BNO055 USB Stick Python driver

PyPI version

TL;DR: "Swiss army knife" for using BNO055 USB Stick under Linux from python3.

BNO055 USB Stick comes with Development Desktop 2.0 software package, which is available for Windows only.

If you have a BNO055 USB Stick and want to use it on a Linux platform (e.g. Ubuntu, Raspbian, Yocto, Suse, etc.) this repo provides you with a python 3 driver, capable of reading / writing registers / burst read, and stream data read.

OS Prerequisites

  1. When plugged in on a Linux system, the BNO055 USB Stick should appear as /dev/ttyACM* device. This device is a so-called cdc_acm (communication device class), but let us leave these details for now.

  2. Your Linux user must be a member of the dialout group (e.g. see this thread) to be able to read/write ttyACM* devices without root privileges.

  3. udev is installed on the system. We do autodetect the USB stick by relying on information from udev.

Installation

pip install bno055_usb_stick_py

Supported Python version

python v3.6+

Python dependencies

TL;DR: install (i) pyserial, (ii) pyudev, (iii) dataclasses (if using python3.6), and (iv) optionally: pyquaternion and matplotlib, or use environment.yml to create conda environment with dependencies resolved.

For further details regarding creating conda senvironment read this guide.

Quick start

Read BNO register:

from bno055_usb_stick_py import BnoUsbStick
bno_usb_stick = BnoUsbStick()
reg_addr = 0x00
reg_val = bno_usb_stick.read_register(reg_addr)
print(f"bno chip id addr: 0x{reg_addr:02X}, value: 0x{reg_val:02X}")

Write register:

from bno055_usb_stick_py import BnoUsbStick
bno_usb_stick = BnoUsbStick()
reg_addr = 0x3F
reg_value = 0x01
bno_usb_stick.write_register(reg_addr, reg_value)
print(f"bno self test started!")

Burst register read:

from bno055_usb_stick_py import BnoUsbStick
bno_usb_stick = BnoUsbStick()
reg_start_addr = 0x08
num_registers = 0x12
burst_read_result = bno_usb_stick.burst_read(reg_start_addr, num_registers)
print(f"bno burst read result: {burst_read_result}")

Get 10 packets in streaming mode (using generator):

from bno055_usb_stick_py import BnoUsbStick

bno_usb_stick = BnoUsbStick()
bno_usb_stick.activate_streaming()
for packet in bno_usb_stick.recv_streaming_generator(num_packets=10):
    print(f"bno data: {packet}")

Get 100 packets in streaming mode (by receiving single packets):

from bno055_usb_stick_py import BnoUsbStick
bno_usb_stick = BnoUsbStick()
bno_usb_stick.activate_streaming()
for _ in range(100):
    packet = bno_usb_stick.recv_streaming_packet()
    print(f"{packet}")

Receive infinite number of packets (in case you wait infinite time 😉 ):

from bno055_usb_stick_py import BnoUsbStick
bno_usb_stick = BnoUsbStick()
bno_usb_stick.activate_streaming()
for packet in bno_usb_stick.recv_streaming_generator():
    print(f"{packet}")

Bno USB Stick Data Packet

When receiving data in streaming mode, the result is an object of BNO055 data class (from bno055.py) file.

BNO055 data class has the following fields:

from bno055_usb_stick_py import BNO055
bno_data = BNO055()
bno_data.a_raw  # raw accelerometer data (a_raw_x, a_raw_y, a_raw_z)
bno_data.g_raw  # raw gyro data (g_raw_x, g_raw_y, g_raw_z)
bno_data.m_raw  # raw magnetometer data (m_raw_x, m_raw_y, m_raw_z)
bno_data.euler_raw  # raw euler angles (heading, roll, pitch)
bno_data.quaternion_raw  # raw quaternion data (q_raw_w, q_raw_x, q_raw_y, q_raw_z)
bno_data.lin_a_raw  # raw linear acceleration data (lin_a_raw_x, lin_a_raw_y, lin_a_raw_z)
bno_data.gravity_raw  # raw gravity vector (gravity_raw_x, gravity_raw_y, gravity_raw_z)
bno_data.a  # accelerometer (a_x, a_y, a_z)
bno_data.g  # gyroscope (g_x, g_y, g_z)
bno_data.m  # magnetometer (m_x, m_y, m_z)
bno_data.euler  # euler angler (heading, roll, pitch)
bno_data.quaternion  # quaternion values (q_w, q_x, q_y, q_z)
bno_data.lin_a  # linear acceleration (lin_a_x, lin_a_y, lin_a_z)
bno_data.gravity  # gravity vector (gravity_x, gravity_y, gravity_z)
bno_data.temp  # temperature register
bno_data.calib_stat  # calibration status (addr 0x35) register
bno_data.st_result  # status result (addr 0x36) register
bno_data.int_sta  # interrupt status (addr 0x37) register
bno_data.sys_clk_status  # system clock status (addr 0x38) register
bno_data.sys_status  # system status (addr 0x39) register

Prevent modem manager to capture serial device

When plugging bno_usb_stick on Ubuntu, the device is unavailable for the first 10-15 seconds, due to the fact that ModemManager process takes over and tries to use the device.

To avoid this Ubuntu-specific behavior, add an exception to the udev rules, s.t. the ModemManager ignores the bno_usb_stick. Run the script:

python disable_modem_manager_bno_usb_stick.py

The script requires root privileges. Essentially it copies the 97-ttyacm.rules file to /etc/udev/rules.d and reloads the udev rules.

Maintainer

Dr. Konstantin Selyunin, for suggestions / questions / comments please contact: selyunin [dot] k [dot] v [at] gmail [dot] com

Metadata

Release files for bno055-usb-stick-py 0.9.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bno055-usb-stick-py 0.9.5
File Size Uploaded
bno055_usb_stick_py-0.9.5.tar.gz 13.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bno055-usb-stick-py 0.9.5
File Interpreter ABI Platform
bno055_usb_stick_py-0.9.5-py3-none-any.whl Python 3 none any Details

Total release size: 26.0 kB

Release files / bno055_usb_stick_py-0.9.5.tar.gz

Download URL bno055_usb_stick_py-0.9.5.tar.gz
Size 13.0 kB
Tags Source
SHA-256 checksum
How to use checksums
c4e2322b47398c8016bb861676c3634c7ead939d440c89a83df91935c93a4769
BLAKE2b-256 checksum
How to use checksums
2e20f96a49e6b224df3d95a5a5633b38f368712d4e29b8499b90a75f04c189cb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.7

Release files / bno055_usb_stick_py-0.9.5-py3-none-any.whl

Download URL bno055_usb_stick_py-0.9.5-py3-none-any.whl
Size 13.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c45211022bd65a34591477df96ed6966804a17444ad804ce3bb94f4d1afc1497
BLAKE2b-256 checksum
How to use checksums
743f7446a988be7587bd99bbc25ba685fb259b8281ece9ec2f0d574ca85f0e66
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.7

Release history Release notifications | RSS feed

This release

0.9.5 This release

2 release files

0.9.3

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page