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

Re: Pico and BNO055 IMU

Post by Thomas_G_S » Tue Jan 04, 2022 9:03 pm

Done that and still getting the error. I've tried using Micropython and it seems to have fixed that problem, however it now says: "RuntimeError: No BNO055 chip detected."

I have the Adafruit BNO055 plugged in using GPIO 0 and GPIO 1. Do I need to activate SCL and SDA somehow?

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 9:27 pm

GPIO0 and 1 are assigned to I2C(0), but bno055_test.py uses I2C(1). You either have to change bno055_test.py, line 10, or connect the sensor to GPIO2 (SDA) and 3 (SCL).

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 9:36 pm

I'm getting data now, THANK YOU!!! :) :) :)

Only one problem - after around 1.5 seconds the data stops coming in and I get the following error:

Traceback (most recent call last):
File "<stdin>", line 22, in <module>
File "/lib/bno055_base.py", line 89, in <lambda>
File "/lib/bno055_base.py", line 118, in scaled_tuple
File "/lib/bno055_base.py", line 200, in _readn
OSError: [Errno 5] EIO

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 9:45 pm

That's an I2C communication error.

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 9:47 pm

So is it a hardware issue?

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

Re: Pico and BNO055 IMU

Post by Roberthh » Wed Jan 05, 2022 6:49 am

Maybe, but more likely a synchronization or wiring problem. You could try running I2C at a lower frequency, by setting:

i2c = machine.I2C(1, freq=100000)

or even less. If it then works, then there is an issue with the wiring, like wires too long or pull-up resistors to large.

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

Re: Pico and BNO055 IMU

Post by pythoncoder » Wed Jan 05, 2022 10:55 am

On the Pico you need physical pullup resistors. Anything in the region of 1KΩ to 4.7KΩ connected between SDA and 3.3V and between SCK and 3.3V.
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 » Wed Jan 05, 2022 11:23 am

The pico is now unable to detect the gyro. When I try to run the program I get this:

Traceback (most recent call last):
File "<stdin>", line 13, in <module>
File "/lib/bno055.py", line 127, in __init__
File "/lib/bno055_base.py", line 96, in __init__
RuntimeError: No BNO055 chip detected.


I have run a program to search for I2C devices, and it's able to find it:

Scanning i2c bus
i2c devices found: 1
Decimal address: 40 | Hexa address: 0x28

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

Re: Pico and BNO055 IMU

Post by pythoncoder » Wed Jan 05, 2022 12:07 pm

Your scan shows it's at the correct address but the first attempt to read from it failed. Clearly I2C access is inconsistent. Please check the hardware issues raised by myself and @RobertHH.
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 » Wed Jan 05, 2022 12:16 pm

I've put resistors in the scl and sda lines. Is that what you mean? I've also tried lowering the frequency, but that hasn't worked either.

Post Reply