How fast get you read the BNO055?
I am trying to collect some high frequency accelerometer data for a machine learning hobby project. Since I had the Adafruit BNO055 board lying around, that was my first thing to explore. Early experimentation tells me that I should aim for ~4ksps (kilosamples per second), because I think some signal lie in vibrations that are audible. According to the data sheet, the BNO055 has a setting for 1ksps in accelerometer-only mode, so that is what I will try!
I set up my Raspberry Pi, connected via I2C, ran pip install adafruit-circuitpython-bno055
and wrote a small benchmark program. I call it slower.py
, because it did not get 1ksps, and I thought this was because of overhead in python or possibly in the library of Adafruit. It made me obtain ca 500sps, only half of the promised sample rate!
So to dig deeper, and see where the bottle neck is, I implemented a C library to go with the test runner. The new runner, and the library are called faster.py
and faster.c
because I expected them to be faster. They were not, and produced only 500sps as well. Here is the test runner, for reference. You can see it is virtually the same as before.
This lead me to believe the problem was in the python environment. I updated the C code so it can be compiled either as a shared library/DLL, or as an executable. I am by no means a skilled C programmer, but I got it to run and do what I wanted. See the source code in a github Gist. Unfortunately, I still only got 500sps.
Apparently the BNO055 is slow. Searching online says it has something to do with clock stretching - if the BNO055 don’t have data available, it can slow the baudrate of the I2C clock line. In the end, I went another route, and will use some other hardware.