Due to high demand, expect some shipping delays at this time - orders may not ship for up to 2-3 business days.
0

Feather M4 + BNO085 I/O error
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Feather M4 + BNO085 I/O error

by askker on Fri Sep 03, 2021 4:05 am

Hi,

I followed every step in the instruction and tried to run the example code. The code would spit out several acceleration vectors but it always ends with an Input/output error. What am I doing wrong here? The setup is shown in the picture below:
20210903_075435247_iOS 2.jpg
20210903_075435247_iOS 2.jpg (629.22 KiB) Viewed 1068 times


My code:
Code: Select all | TOGGLE FULL SIZE
import time
import board
import busio
from adafruit_bno08x.i2c import BNO08X_I2C
from adafruit_bno08x import BNO_REPORT_ACCELEROMETER

i2c = busio.I2C(board.SCL, board.SDA, frequency=400000)
bno = BNO08X_I2C(i2c)
bno.enable_feature(BNO_REPORT_ACCELEROMETER)

while True:
    time.sleep(1)
    accel_x, accel_y, accel_z = bno.acceleration  # pylint:disable=no-member
    print("X: %0.6f  Y: %0.6f Z: %0.6f  m/s^2" % (accel_x, accel_y, accel_z))


Output:
Code: Select all | TOGGLE FULL SIZE
Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.

code.py output:

X: -0.304688  Y: -1.417969 Z: 9.578125  m/s^2

X: -0.304688  Y: -1.378906 Z: 9.613281  m/s^2

X: -0.304688  Y: -1.417969 Z: 9.578125  m/s^2

Traceback (most recent call last):

  File "code.py", line 117, in <module>

  File "adafruit_bno08x/__init__.py", line 601, in acceleration

  File "adafruit_bno08x/__init__.py", line 796, in _process_available_packets

  File "adafruit_bno08x/__init__.py", line 794, in _process_available_packets

  File "adafruit_bno08x/i2c.py", line 122, in _read_packet

  File "adafruit_bno08x/i2c.py", line 144, in _read

  File "adafruit_bno08x/i2c.py", line 144, in _read

OSError: [Errno 5] Input/output error



Code done running.

askker
 
Posts: 12
Joined: Fri Sep 03, 2021 3:57 am

Re: Feather M4 + BNO085 I/O error

by adafruit_support_carter on Tue Sep 07, 2021 12:52 pm

Maybe there's a marginal connection on the mating cables - between the Feather and the STEMMA QT cable.

Does the error always happen after the same amount of readings?

Are you moving the BNO or Feather?

adafruit_support_carter
 
Posts: 23506
Joined: Tue Nov 29, 2016 2:45 pm

Re: Feather M4 + BNO085 I/O error

by askker on Tue Sep 07, 2021 6:42 pm

adafruit_support_carter wrote:Maybe there's a marginal connection on the mating cables - between the Feather and the STEMMA QT cable.

Does the error always happen after the same amount of readings?

Are you moving the BNO or Feather?


Could be, I tried a shorter mating cable and looks like it would run a bit longer before crash (20-30 sec). But the connection seems to be good, I can shake it however I want and it still works for like 30 seconds and then give me the IO error. The error always happends, but not necessarily the same amount of readings, sometimes it reads ~40 times (2hz) and other times it reads ~60 times.

Can you confirm that M4+bno085+simple_test,py is able to work without problem > 2 min? I'm thinking if my m4 is defective. Because the same bno085 sensor works just fine with mkr1000.

askker
 
Posts: 12
Joined: Fri Sep 03, 2021 3:57 am

Re: Feather M4 + BNO085 I/O error

by askker on Tue Sep 07, 2021 7:19 pm

Update: Something strange just happen, I unplug the feather from my desktop and used a laptop to test it again. Now the feather is working perfectly, no more IO error (worked 5 min+ non stop). What could be going on here? Is the power supply from my desktop USB somehow messing up the feather i2c? I tried it on both of my desktop and non worked.

askker
 
Posts: 12
Joined: Fri Sep 03, 2021 3:57 am

Re: Feather M4 + BNO085 I/O error

by adafruit_support_carter on Tue Sep 07, 2021 7:30 pm

It could be power related. There shouldn't be too much power demand for just the Feather + BNO. But it still might be trying to draw more than to particular port can deliver.

Can you keep testing with other USB ports and see if you can determine if the behavior is specific to that one PC?

adafruit_support_carter
 
Posts: 23506
Joined: Tue Nov 29, 2016 2:45 pm

Re: Feather M4 + BNO085 I/O error

by askker on Wed Sep 08, 2021 3:11 pm

adafruit_support_carter wrote:It could be power related. There should be too much power demand for just the Feather + BNO. But it still might be trying to draw more than to particular port can deliver.

Can you keep testing with other USB ports and see if you can determine if the behavior is specific to that one PC?


I've tried 3 desktop and 2 laptops, here are the results:

Laptop 1 ThinkPad: Works
Laptop 2 Macbook Pro: Works
Desktop 1 HP Desktop: Works
Desktop 2 Old DIY Desktop: Does not work
Desktop 3 New DIY Desktop: Does not work

I also notice that the two desktops that don't work shares the same power stripe, could it be a common ground problem? As for the power consumption, I believe the feather has a 500mA limit so it should not be able to exceed what usb on PC usually offers (500mA). How should I proceed?

askker
 
Posts: 12
Joined: Fri Sep 03, 2021 3:57 am

Re: Feather M4 + BNO085 I/O error

by gammaburst on Wed Sep 08, 2021 3:23 pm

Try this simple test. It may seem weird, but there's science behind it.

Attach a short wire to signal SDA. Grab the bare end of the wire with two fingers. While holding it, restart the project and observe if it behaves better or worse. Then move the wire to SCL and try again.

Your finger should not disturb the operation of the I2C bus. If it does, we'll try a simple fix.

gammaburst
 
Posts: 701
Joined: Thu Dec 31, 2015 12:06 pm

Re: Feather M4 + BNO085 I/O error

by adafruit_support_carter on Wed Sep 08, 2021 3:52 pm

The power issue would relate more to what amount of total current the host USB port could deliver.

It's working on 3 other machines, so we know the Feather/BNO hardware is OK. You could try moving power on those other two machines, but that does not seem like a potential cause. Is there anything unique to those USB ports?

adafruit_support_carter
 
Posts: 23506
Joined: Tue Nov 29, 2016 2:45 pm

Re: Feather M4 + BNO085 I/O error

by gammaburst on Wed Sep 08, 2021 6:26 pm

If anyone is interested, here are oscilloscope captures of the USB current into my Feather M4 and Adafruit BNO08x breakout running an Arduino sketch that outputs 100 quaternions per second. I used a Tektronix TCP202 Current Probe.

First capture shows zero current, then USB plug-in, then about one second later (near center of the sweep) steady serial data output begins. The vertical axis is 20.0 mA per division, so the average current is around 36 mA.

Second capture is zoomed-in to show the initial inrush pulse. Vertical axis is 1.00 A per division. It shows zero current, then USB plug-in, then a very brief inrush pulse of about 3.4 amps, then another inrush pulse approaching 2 amps also very brief about 60 us. If I were to use a different USB hub, the pulse shapes would probably look different.

That all seems normal to me.
Attachments
FeatherM4+BNO08x, USB current, zoomed-out showing USB plug-in then startup, then data transmission, annotated.png
FeatherM4+BNO08x, USB current, zoomed-out showing USB plug-in then startup, then data transmission, annotated.png (32.5 KiB) Viewed 976 times
FeatherM4+BNO08x, USB current, zoomed-in to USB plug-in, annotated.png
FeatherM4+BNO08x, USB current, zoomed-in to USB plug-in, annotated.png (9.43 KiB) Viewed 976 times

gammaburst
 
Posts: 701
Joined: Thu Dec 31, 2015 12:06 pm

Re: Feather M4 + BNO085 I/O error

by askker on Wed Sep 08, 2021 9:09 pm

gammaburst wrote:Try this simple test. It may seem weird, but there's science behind it.

Attach a short wire to signal SDA. Grab the bare end of the wire with two fingers. While holding it, restart the project and observe if it behaves better or worse. Then move the wire to SCL and try again.

Your finger should not disturb the operation of the I2C bus. If it does, we'll try a simple fix.


When the wire is attached to SDA, the second I touch it feather would spit out IO error. When the wire is attached to SCL, still works perfectly regardless of my touch. This is quite amazing that this would reliably reproduce the error!

What should the fix be?

askker
 
Posts: 12
Joined: Fri Sep 03, 2021 3:57 am

Re: Feather M4 + BNO085 I/O error

by askker on Wed Sep 08, 2021 9:13 pm

adafruit_support_carter wrote:The power issue would relate more to what amount of total current the host USB port could deliver.

It's working on 3 other machines, so we know the Feather/BNO hardware is OK. You could try moving power on those other two machines, but that does not seem like a potential cause. Is there anything unique to those USB ports?


I did more test and looks like there is nothing unique about those USB ports. I removed all the other usb devices to make sure it has as much power supply as possble and it still wouldn't work. I also tried different usb ports (front, back, 2.0, 3.0) and got the same result.

askker
 
Posts: 12
Joined: Fri Sep 03, 2021 3:57 am

Re: Feather M4 + BNO085 I/O error

by adafruit_support_carter on Thu Sep 09, 2021 12:22 pm

Really weird behavior. Not sure what it could be, but it's unique to those machines.

adafruit_support_carter
 
Posts: 23506
Joined: Tue Nov 29, 2016 2:45 pm

Re: Feather M4 + BNO085 I/O error

by gammaburst on Thu Sep 09, 2021 3:35 pm

Hi askker,

Short answer: Install an additional pullup resistor, around 2K to 3K ohms, from SDA to 3.3V. Leave SCL alone. Your project will probably now run reliably.

Long answer: Your SDA/SCL touch-test results agree with mine. Your project, and every other BNO08X and BNO055 project, are on the verge of failure due to an I2C hardware timing bug in the BNO08X (and BNO055). During an I2C clock-stretching bus cycle, the bug occasionally causes violation of the SDA-high to SCL-high setup time, and if that violation is sufficiently large then the I2C transfer will fail. If you slow down SDA's rise time by a few nanoseconds (by grabbing it with your finger), the timing error worsens and your I2C transfer fails. If you slow down SCL's rise time by a few nanoseconds (by grabbing it with your finger), the timing error reduces and your I2C transfer works more reliably. Adding the aforementioned pullup resistor speeds-up SDA's risetime by many nanoseconds, and although that's insufficient to eliminate the timing error, it reduces the error sufficiently to avoid failure in all the projects that I've seen.

Those are my opinions and experiences. Corrections are welcome.

gammaburst
 
Posts: 701
Joined: Thu Dec 31, 2015 12:06 pm

Re: Feather M4 + BNO085 I/O error

by adafruit_support_carter on Thu Sep 09, 2021 3:44 pm

Interesting. Could this explain why it works on 3 machines but not the other 2?

adafruit_support_carter
 
Posts: 23506
Joined: Tue Nov 29, 2016 2:45 pm

Re: Feather M4 + BNO085 I/O error

by gammaburst on Thu Sep 09, 2021 4:14 pm

Hi Mike,

I wouldn't expect swapping computers to affect the BNO's I2C timing bug, but weirder things have happened.

Swapping microcontrollers, however, does affect the I2C timing problem. For example, an Arduino Uno with BNO usually requires a firmer squeeze of the SDA wire to cause failure, whereas an M4 Feather with BNO requires less squeeze (or none at all) for failure. I noticed that while trying various combinations.

By the way, a variation of my pullup resistor workaround is in Adafruit's BNO055 FAQ:
https://learn.adafruit.com/adafruit-bno ... ensor/faqs

gammaburst
 
Posts: 701
Joined: Thu Dec 31, 2015 12:06 pm

Please be positive and constructive with your questions and comments.