4

I'm running scripts on a Raspberry Pi 3 hooked up to an Adafruit BNO055 sensor, and occasionally when I run the test script I get this error:

   Traceback (most recent call last):
      File "simpletest.py", line 45, in <module>
        if not bno.begin():
      File "/usr/local/lib/python2.7/dist-packages/Adafruit_BNO055-1.0.2-py2.7.egg/Adafruit_BNO055/BNO055.py", line 385, in begin
      File "/usr/local/lib/python2.7/dist-packages/Adafruit_BNO055-1.0.2-py2.7.egg/Adafruit_BNO055/BNO055.py", line 346, in _read_byte
      File "/usr/local/lib/python2.7/dist-packages/Adafruit_BNO055-1.0.2-py2.7.egg/Adafruit_BNO055/BNO055.py", line 331, in _read_bytes
    RuntimeError: Register read error: 0xee06

I'm unfortunately new to using RPis and don't know how to proceed to fix this. Is this an error with the registry of the Raspberry Pi, or something to do with the sensor?

gsamerica
  • 41
  • 2
  • Have you enabled the serial port properly (see [this question](https://raspberrypi.stackexchange.com/q/45570/58316)) and disabled the "Baudrate derived from system clock" feature? – Aurora0001 Jan 07 '18 at 10:19

3 Answers3

1

I do not now the reason for this bug but on my setup it seems that if you try to start the script again a few times it will end up working.

A hacky fix is to catch the exception and try again.

Replace these lines:

# Initialize the BNO055 and stop if something went wrong.
if not bno.begin():
    raise RuntimeError('Failed to initialize BNO055! Is the sensor connected?')

# Print system status and self test result.
status, self_test, error = bno.get_system_status()

With something like:

while True:
    try:
        # Initialize the BNO055 and stop if something went wrong.
        if not bno.begin():
            raise RuntimeError('Failed to initialize BNO055! Is the sensor connected?')
        # Print system status and self test result.
        status, self_test, error = bno.get_system_status()
        break
    except Exception as e:
        print("Got error: {}".format(e))
        print("Sleeping 1s before retrying")
        time.sleep(1)
0

As per one thread (could not find it), the issue happens when the serial port that BNO055 is connected to is also being used by Bluetooth. So, you can try disabling bluetooth. Also, you can use the other serial port in the Raspberry Pi 3. Pi 3 has two serial ports.

I am using Pi 4 and after using uart5, I am not getting that issue.

For raspberry pi, the default I2C bus seems to have clock-stretching issue. Use software driven I2C bus instead. For doing this,

  1. Enable I2C interface from raspi-config and then reboot.
  2. Append "dtoverlay=i2c-gpio,bus=3" to /boot/config.txt file and then reboot.
  3. Connect the BNO055 to the I2C-3 bus. SDA will be on GPIO23 and SCL will be on GPIO24 which are pins 16 and 18 on the GPIO header respectively.
  4. In file BNO055.py from Adafruit_Python_BNO055, replace this line "self._i2c_device = i2c.get_i2c_device(address, **kwargs)" with "self._i2c_device = i2c.get_i2c_device(address, 3, **kwargs)" so that I2C bus 3 is used instead of the default bus.
  5. Instead of initializing BNO055 "BNO055.BNO055(serial_port=PORT, rst=RESET_PIN)", initialize it as "BNO055.BNO055(rst=RESET_PIN)".

During my short test of about 10 minutes, I did not encounter any error while using i2c bus.

spockshr
  • 121
  • 2
0

You will have to look at the indicated lines in the script to determine the underlying error.

It could be a bug in the script (not reacting properly to a returned status) or an error in the sensor or wiring.

At a guess a bug in the script is more likely.

joan
  • 67,803
  • 5
  • 67
  • 102