BNO055 USB Stick Linux Python Driver
Project description
BNO055 USB Stick Python driver
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
-
When plugged in on a Linux system, the
BNO055 USB Stick
should appear as/dev/ttyACM*
device. This device is a so-calledcdc_acm
(communication device class), but let us leave these details for now. -
Your Linux user must be a member of the
dialout
group (e.g. see this thread) to be able to read/writettyACM*
devices without root privileges. -
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}")
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
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for bno055_usb_stick_py-0.9.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1dc1a7ba91ea15e824223ad5da57c9f1e099f08719da786b31f7ce6c7b01487a |
|
MD5 | 70159e6e5ba8878add6a9699dcdf2cff |
|
BLAKE2b-256 | 113b8bfcf853f02665449ec18dbc57adf42990d30f4881467485edbeb6002e8c |
Hashes for bno055_usb_stick_py-0.9.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ce65756065076da48124b7b59844005b0f80f9d8aea8732faf82a9dbbdfe52b1 |
|
MD5 | 162428a7f8f540225da884e16c042904 |
|
BLAKE2b-256 | 7a047d1665b0c6acd42cdab238302b1addfd985163bbb6e429693e29d7bff250 |