Problems using BNO085 IMU with Pi Zer0 W

After following Adafuit’s guide, I am struggling to run bno08x_simpletest.py with I2C on a Pi Zero W.

I looked at Adafruit’s known issues but they didn’t appear relevant.

I know that clock stretching is an issue with the BNO055, so I again inserted dtparam=i2c_arm_baudrate=10000 into /boot/config.txt but I still get the output below.

I would appreciate any help to get data.

%Run bno08x_simpletest.py
Acceleration:

	********** Packet *************

DBG:: HEADER:
DBG:: Data Len: 15
DBG:: Channel: INPUT_SENSOR_REPORTS (3)
DBG:: ** UNKNOWN Report Type **: 0x7b
DBG:: Sequence number: 47

DBG:: Data:
DBG:: [0x04] 0x7B 0x24 0x00 0x00
DBG:: [0x08] 0x00 0x02 0x0D 0x00
DBG:: [0x0C] 0x00 0xFF 0xFF 0x04
DBG:: [0x10] 0x00 0x00 0x00
*******************************

Traceback (most recent call last):
File “/home/pi/bno08x_simpletest.py”, line 27, in
accel_x, accel_y, accel_z = bno.acceleration # pylint:disable=no-member
File “/usr/local/lib/python3.7/dist-packages/adafruit_bno08x/init.py”, line 589, in acceleration
self._process_available_packets()
File “/usr/local/lib/python3.7/dist-packages/adafruit_bno08x/init.py”, line 785, in _process_available_packets
self._handle_packet(new_packet)
File “/usr/local/lib/python3.7/dist-packages/adafruit_bno08x/init.py”, line 843, in _handle_packet
raise error
File “/usr/local/lib/python3.7/dist-packages/adafruit_bno08x/init.py”, line 838, in _handle_packet
_separate_batch(packet, self._packet_slices)
File “/usr/local/lib/python3.7/dist-packages/adafruit_bno08x/init.py”, line 353, in _separate_batch
required_bytes = _report_length(report_id)
File “/usr/local/lib/python3.7/dist-packages/adafruit_bno08x/init.py”, line 342, in _report_length
return _AVAIL_SENSOR_REPORTS[report_id][2]
KeyError: 123

Hi Richard,

Welcome to the forums :slight_smile:

I’ll go grab one of these off the shelf and have a go at getting it setup. Will be back shortly with some more info!

Thanks Oliver.

1 Like

This may help identify the issue?:

%Run 'python3 blinkatest.py'
Hello blinka!
Digital IO ok!
I2C ok!
Traceback (most recent call last):
  File "/home/pi/python3 blinkatest.py", line 16, in <module>
    spi = busio.SPI(board.SCLK, board.MOSI, board.MISO)
  File "/usr/local/lib/python3.7/dist-packages/busio.py", line 186, in __init__
    self._spi = _SPI(portId)
  File "/usr/local/lib/python3.7/dist-packages/adafruit_blinka/microcontroller/generic_linux/spi.py", line 22, in __init__
    self._spi = spi.SPI(device=(portid, 0))
  File "/usr/local/lib/python3.7/dist-packages/Adafruit_PureIO/spi.py", line 167, in __init__
    raise IOError("{} does not exist".format(device))
OSError: /dev/spidev0.0 does not exist
1 Like

Hey Richard,

Just a quick check while I’m waiting for updates on our Pi Zero - did you install the blinka library correctly:

I had assumed that the blikatest.py output above is evidence that the library is correctly installed, or not?

Hey Richard,

It may not be that there’s an error with whether it’s installed correctly, but rather than the implementation is causing an issue in this project. From reading over the output and error messages, it appears that there’s currently an issue with the particular script that you’ve got as it is consistently failing on line 16. Could you please upload the script that you’re currently running? I’ll take a look over it and see whether I can spot where this bug is coming up for you.

The scripts is Adafruit_CircuitPython_BNO08x/bno08x_simpletest.py at master · adafruit/Adafruit_CircuitPython_BNO08x · GitHub

No worries,

Out of curiosity, can we quickly check that busio is imported correctly. I can’t think of any other reason why the script continuously trips on this line. If you enter a terminal, type python to open up a CLI and then type import busio followed by busio we should get an echo back to confirm that the library is correctly imported and valid.

This is the line that we appear to be having issues with, we’re looking into what’s causing that here now. spi = busio.SPI(board.SCLK, board.MOSI, board.MISO)

pi@raspberrypi:~ $ python
Python 2.7.16 (default, Oct 10 2019, 22:02:15)
[GCC 8.3.0] on linux2
Type “help”, “copyright”, “credits” or “license” for more information.

import busio
Traceback (most recent call last):
File “”, line 1, in
ImportError: No module named busio

I’m going to get another memory card to build from scratch; will be back in an hour.
Thanks
Richard

Hi Richard,

Sounds like a plan, it’s certainly that the library isn’t installed properly by the look of it. Please let us know how you go!

pi@raspberrypi:~ sudo pip3 install adafruit-circuitpython-bno08x Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple Requirement already satisfied: adafruit-circuitpython-bno08x in /usr/local/lib/python3.7/dist-packages (1.0.3) Requirement already satisfied: adafruit-circuitpython-busdevice in /usr/local/lib/python3.7/dist-packages (from adafruit-circuitpython-bno08x) (5.0.1) Requirement already satisfied: Adafruit-Blinka in /usr/local/lib/python3.7/dist-packages (from adafruit-circuitpython-bno08x) (5.9.0) Requirement already satisfied: RPi.GPIO in /usr/lib/python3/dist-packages (from Adafruit-Blinka->adafruit-circuitpython-bno08x) (0.7.0) Requirement already satisfied: pyftdi>=0.40.0 in /usr/local/lib/python3.7/dist-packages (from Adafruit-Blinka->adafruit-circuitpython-bno08x) (0.52.0) Requirement already satisfied: sysv-ipc in /usr/local/lib/python3.7/dist-packages (from Adafruit-Blinka->adafruit-circuitpython-bno08x) (1.0.1) Requirement already satisfied: Adafruit-PlatformDetect>=2.18.1 in /usr/local/lib/python3.7/dist-packages (from Adafruit-Blinka->adafruit-circuitpython-bno08x) (2.23.0) Requirement already satisfied: Adafruit-PureIO>=1.1.7 in /usr/local/lib/python3.7/dist-packages (from Adafruit-Blinka->adafruit-circuitpython-bno08x) (1.1.8) Requirement already satisfied: rpi-ws281x>=4.0.0 in /usr/local/lib/python3.7/dist-packages (from Adafruit-Blinka->adafruit-circuitpython-bno08x) (4.2.5) Requirement already satisfied: pyserial>=3.0 in /usr/lib/python3/dist-packages (from pyftdi>=0.40.0->Adafruit-Blinka->adafruit-circuitpython-bno08x) (3.4) Requirement already satisfied: pyusb>=1.0.0 in /usr/local/lib/python3.7/dist-packages (from pyftdi>=0.40.0->Adafruit-Blinka->adafruit-circuitpython-bno08x) (1.1.0) pi@raspberrypi:~

Hi Richard,

What happens if you also run sudo pip3 install adafruit-blinka? Also you’re certainly running this on Python3?

pi@raspberrypi:~ sudo pip3 install adafruit-blinka Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple Requirement already satisfied: adafruit-blinka in /usr/local/lib/python3.7/dist-packages (5.9.0) Requirement already satisfied: Adafruit-PlatformDetect>=2.18.1 in /usr/local/lib/python3.7/dist-packages (from adafruit-blinka) (2.23.0) Requirement already satisfied: sysv-ipc in /usr/local/lib/python3.7/dist-packages (from adafruit-blinka) (1.0.1) Requirement already satisfied: Adafruit-PureIO>=1.1.7 in /usr/local/lib/python3.7/dist-packages (from adafruit-blinka) (1.1.8) Requirement already satisfied: RPi.GPIO in /usr/lib/python3/dist-packages (from adafruit-blinka) (0.7.0) Requirement already satisfied: rpi-ws281x>=4.0.0 in /usr/local/lib/python3.7/dist-packages (from adafruit-blinka) (4.2.5) Requirement already satisfied: pyftdi>=0.40.0 in /usr/local/lib/python3.7/dist-packages (from adafruit-blinka) (0.52.0) Requirement already satisfied: pyserial>=3.0 in /usr/lib/python3/dist-packages (from pyftdi>=0.40.0->adafruit-blinka) (3.4) Requirement already satisfied: pyusb>=1.0.0 in /usr/local/lib/python3.7/dist-packages (from pyftdi>=0.40.0->adafruit-blinka) (1.1.0) pi@raspberrypi:~

Regarding the python version, I checked per below, and it seems 2.7, however my BNO055 ran perfectly from Thonny?
pi@raspberrypi:~ $ python
Python 2.7.16 (default, Oct 10 2019, 22:02:15)
[GCC 8.3.0] on linux2
Type “help”, “copyright”, “credits” or “license” for more information.

Thonny shell
Python 3.7.3 (/usr/bin/python3)

So my Pi has the BNO055 and BNO085 libraries installed, but only the BNO055 runs!

Hi Richard,

How unusual, we’re still working on the setup of this at the moment with the BNO085 in the office, Oliver will be keeping you updated as we work on possible solutions to get this working. We managed to get some functionality earlier running with a Pi Zero but it kept crashing. We’re going to try and replicate it on another board. We’ll keep you in the loop as we solve this.

Much appreciated! I did briefly get some data this morning (excluding the quarternions which I need), but have not been able to replicate this.

Hi Richard,

At this stage, our best lead is this issue:

With an apparent root cause being issues with clock stretching on a Pi. Apparently this is a fix:

Currently loading up the libraries on a Pi 3B+ to see if it’s repeatable on that.

FYI, here’s a capture from a logic analyser at 3MHz sample rate just before data failure:



image

Definitely looks an awful lot like this:
http://www.advamation.com/knowhow/raspberrypi/rpi-i2c-bug.html

We’ve run out of time today, but if you keep at it this evening/tonight, please let us know how you get on!

1 Like

Did you try the software I2C driver?
As mentioned, I did try inserting dtparam=i2c_arm_baudrate=10000 into /boot/config.txt per Adafruit’s guide This worked for the BNO055 but not BNO085.