micropython-IMU/micropython-bno055

random errors with

efremovru opened this issue · 9 comments

Peter, i downloaded and installed the driver per your instructions. It started right away and produced meaningful data (all i care is the heading) but then it stopped and produced the error below

Traceback (most recent call last):
File "", line 23, in
File "bno055_base.py", line 94, in temperature
File "bno055_base.py", line 113, in _read
OSError: [Errno 110] ETIMEDOUT

i restarted and got similar but not the same error. no changes to the code !!!!!

Traceback (most recent call last):
File "", line 26, in
File "bno055_base.py", line 60, in
File "bno055_base.py", line 91, in scaled_tuple
File "bno055_base.py", line 123, in _readn
OSError: [Errno 110] ETIMEDOUT

i tried again and got the same results

File "", line 21, in
File "bno055_base.py", line 107, in calibrated
File "bno055_base.py", line 99, in cal_status
File "bno055_base.py", line 113, in _read
OSError: [Errno 110] ETIMEDOUT

my breadboard is super simple BNO, ESP32 and nothing else. I am using PIN 16 for sda and and PIN 17 for scl. I am pulling them up via code per the MicroPython reference page.

from machine import Pin, SoftI2C
import time
from bno055 import *

sda=Pin(16,Pin.PULL_UP)
scl=Pin(17,Pin.PULL_UP)

i2c = SoftI2C(scl, sda, freq=100000)
i2c.init(scl,sda,freq = 100000)

the rest of the code is AS IS. The ESP32 is HiLetgo ESP-WROOM-32 ESP32 ESP-32S

I assume that i am doing something wrong but not sure what. Can you please advise?

This is almost certainly a hardware fault. The internal pullups are not strong enough for I2C. I recommend external resistors pulling up to 3.3V. The value is not critical, anywhere in the range 1KΩ to 10KΩ should be OK.

Peter, i agree that the randomness of the error points to hardware problem but since the breadboard is as simple as it can be, I am stumped what can i do differently. It is a breadboard so the I2C is less than an inch long and there is nothing else on it. I tried your suggestion with both 1K and 3.3K external pull-ups. Unfortunately, there is no change in the outcome.

Heading 289 roll 73 pitch 53
Calibration required: sys 3 gyro 3 accel 0 mag 3
Temperature 25°C
Mag x -2 y 19 z 43
Gyro x -72 y 311 z 117
Accel x -1.4 y -2.7 z -6.9
Lin acc. x 1.0 y 1.3 z 1.7
Gravity x -2.1 y -3.9 z -8.8
Traceback (most recent call last):
File "", line 29, in
File "bno055_base.py", line 64, in
File "bno055_base.py", line 91, in scaled_tuple
File "bno055_base.py", line 123, in _readn
OSError: [Errno 110] ETIMEDOUT

PS: i tried another ESP board. same result

If your ESP boards have SPIRAM the problem may be your choice of pins. See this doc.

Same Problem on a NUCLEO_H743ZI2 Board:
Traceback (most recent call last):
File "/home/.../micropython/main.py", line 43, in
File "bno055_base.py", line 86, in
File "bno055_base.py", line 118, in scaled_tuple
File "bno055_base.py", line 200, in _readn
OSError: [Errno 110] ETIMEDOUT

Have you fitted pullups as described above?

Yes and this was not the error.
It was the timeout time for the I2C bus.
I declared a larger timeout time and everything worked fine.
The standard time was to short.
@efremovru
increase the timeout time from i2c = SoftI2C(scl, sda, freq=100000) to i2c = SoftI2C(scl, sda, freq=100000, timeout=500)

OK, thanks for that. Most of my testing was with hard I2C. The datasheet seems to lack timing information on the I2C bus, so the correct value for the timeout is guesswork.

I have put a note in the README file.

@pavarott

I have studied this in connection with the RP2 chip. The BNO055 performs clock stretching to varying degrees. The longest I measured was 500μs. You might want to increase your timeout value to give a better margin, say to 1000μs.