Pico and BNO055 IMU

RP2040 based microcontroller boards running MicroPython.
Target audience: MicroPython users with an RP2040 boards.
This does not include conventional Linux-based Raspberry Pi boards.
Thomas_G_S
Posts: 18
Joined: Mon Jan 03, 2022 1:29 pm

Pico and BNO055 IMU

Post by Thomas_G_S » Mon Jan 03, 2022 1:37 pm

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

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Pico and BNO055 IMU

Post by Roberthh » Mon Jan 03, 2022 5:14 pm

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.

sonnybalut
Posts: 11
Joined: Tue Dec 22, 2020 7:19 pm

Re: Pico and BNO055 IMU

Post by sonnybalut » Mon Jan 03, 2022 11:15 pm

Here is my youtube demo, source in the description

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

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Pico and BNO055 IMU

Post by pythoncoder » Tue Jan 04, 2022 2:04 pm

If you want to use Adafruit drivers, it may be easier to use CircuitPython as well for your board.
Or use this MicroPython driver.
Peter Hinch
Index to my micropython libraries.

Thomas_G_S
Posts: 18
Joined: Mon Jan 03, 2022 1:29 pm

Re: Pico and BNO055 IMU

Post by Thomas_G_S » Tue Jan 04, 2022 5:30 pm

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 :)

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Pico and BNO055 IMU

Post by Roberthh » Tue Jan 04, 2022 6:44 pm

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.

Thomas_G_S
Posts: 18
Joined: Mon Jan 03, 2022 1:29 pm

Re: Pico and BNO055 IMU

Post by Thomas_G_S » Tue Jan 04, 2022 8:09 pm

Ok, I'll try them both out. Thanks! Btw, how would I install a library onto Pico that isn't on Thonny?

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Pico and BNO055 IMU

Post by Roberthh » Tue Jan 04, 2022 8:18 pm

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, ...

Thomas_G_S
Posts: 18
Joined: Mon Jan 03, 2022 1:29 pm

Re: Pico and BNO055 IMU

Post by Thomas_G_S » Tue Jan 04, 2022 8:47 pm

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

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Pico and BNO055 IMU

Post by Roberthh » Tue Jan 04, 2022 8:53 pm

Did you copy both bno055.py and bno055_base.py?
As first step, I would try bno055_test.py.

Post Reply