Page 1 of 6

Pico and BNO055 IMU

Posted: Mon Jan 03, 2022 1:37 pm
by Thomas_G_S
Hello

I'm trying to get my Raspberry Pi Pico to collect data from the adafruit BNO055 IMU breakout using Micropython. So far I have this code:

import adafruit_bno055
import machine

i2c = machine.I2C(0, scl=machine.Pin(1), sda=machine.Pin(0))
sensor = adafruit_bno055.BNO055_I2C(i2c)

print(sensor.temperature)
print(sensor.euler)
print(sensor.gravity)


and I am getting this error message:

Traceback (most recent call last):
File "<stdin>", line 5, in <module>
File "/lib/adafruit_bno055.py", line 768, in __init__
File "/lib/adafruit_bus_device/i2c_device.py", line 50, in __init__
File "/lib/adafruit_bus_device/i2c_device.py", line 152, in __probe_for_device
AttributeError: 'I2C' object has no attribute 'try_lock'


can anyone help me?


Thanks

Re: Pico and BNO055 IMU

Posted: Mon Jan 03, 2022 5:14 pm
by Roberthh
The Adafruit dialect of MicroPython called CircuitPython is different from the genuine MicroPyhon. If you want to use Adafruit drivers, it may be easier to use CircuitPython as well for your board.

Re: Pico and BNO055 IMU

Posted: Mon Jan 03, 2022 11:15 pm
by sonnybalut
Here is my youtube demo, source in the description

https://www.youtube.com/watch?v=uu4slYGSQPE

Re: Pico and BNO055 IMU

Posted: Tue Jan 04, 2022 2:04 pm
by pythoncoder
If you want to use Adafruit drivers, it may be easier to use CircuitPython as well for your board.
Or use this MicroPython driver.

Re: Pico and BNO055 IMU

Posted: Tue Jan 04, 2022 5:30 pm
by Thomas_G_S
Hello, thanks for getting back to me so quick. Pythoncoder, how would I install that library onto my board? I can't find it on Thonny and I don't know how to install libraries onto Pico without it.

I am now using CircuitPython Roberthh, thanks for the suggestion :)

Re: Pico and BNO055 IMU

Posted: Tue Jan 04, 2022 6:44 pm
by Roberthh
I am now using CircuitPython Roberthh, thanks for the suggestion
I cannot say that I recommend to use CircuitPython. My preference is MicroPython. But everyone has to go for her or his choice, and at least the best part of CircuitPyhton is the MicroPython core.

Re: Pico and BNO055 IMU

Posted: Tue Jan 04, 2022 8:09 pm
by Thomas_G_S
Ok, I'll try them both out. Thanks! Btw, how would I install a library onto Pico that isn't on Thonny?

Re: Pico and BNO055 IMU

Posted: Tue Jan 04, 2022 8:18 pm
by Roberthh
how would I install a library onto Pico that isn't on Thonny?
Just copy the Python script(s) to the board, either to the top level dir or to /lib. For copying, you can use mpremote, rshell, Thonny, ...

Re: Pico and BNO055 IMU

Posted: Tue Jan 04, 2022 8:47 pm
by Thomas_G_S
Ok, I've done that. I'm now running the test code and I'm getting the following error message:

Traceback (most recent call last):
File "<stdin>", line 13, in <module>
NameError: name 'BNO055' isn't defined


I'm using the library that pythoncoder posted earlier:
https://github.com/micropython-IMU/micropython-bno055

Re: Pico and BNO055 IMU

Posted: Tue Jan 04, 2022 8:53 pm
by Roberthh
Did you copy both bno055.py and bno055_base.py?
As first step, I would try bno055_test.py.