Reading BNO055
-
Hi,
I have a WiPy2 with firmware 1.10.0.b4 and want to read data from BNO055 (Adafruit breakout board) via I2C but I always get I2C errors or the device isn't detected. The library is from: https://bitbucket.org/thesheep/micropython-bno055/src
The device is connected as follows:
WiPy2 ------ BNO055
3V3 ---------- Vin
P9 ------------- SDA
P10 ----------- SCL
GND --------- GNDThis is my code:
from machine import Pin, I2C import time i2c = I2C(0, I2C.MASTER, baudrate=1000) print(", ".join([hex(addr) for addr in i2c.scan()])) s = BNO055(i2c) while True: print("t", s.temperature()) print("euler", s.euler()) print("mag ", s.magnetometer()) time.sleep_ms(1000)
I tried different baudrates as well but the device is not detected or the library raises an I2C bus error at
i2c.readfrom_mem(self.address, register, size)
:Traceback (most recent call last): File "<stdin>", line 126, in <module> File "<stdin>", line 47, in __init__ File "<stdin>", line 92, in init File "<stdin>", line 109, in reset File "<stdin>", line 108, in reset File "<stdin>", line 105, in reset File "functools.py", line 5, in _partial File "<stdin>", line 64, in _register File "<stdin>", line 52, in _registers OSError: I2C bus error
I tried I2C with an PCA9685 based PWM board and it's working well.
Any ideas?
-
@incognico said in Reading BNO055:
Maybe try adding some lower value pullup resistors.
From the FAQ page of your device BNO055 FAQ #4
"Depending on your system setup, you might need to adjust the pullups on the SCL and SDA lines to be a bit stronger. The BNO055 has very tight timing requirements on the I2C bus, requiring short setup and rise times on the signals. By default the breakout board has 10K pullups, which might be too weak on some setups."
I had a similar problem. I'm not sure if it's been fixed or not, because I haven't tested it lately. Anyway, it had to do with I2C Clock Stretching. For me the solution was to set the I2C baud rate as low as it would go and work my way up until i found the fastest value that worked. Maybe give that a try, if you haven't already. =)
-
@incognico I tried different pullups from 1.2k to 10k but there is no change. The device works flawless on my OrangePi Zero (ARM device) with 3.3V logic level.
-
Maybe try adding some lower value pullup resistors.
From the FAQ page of your device BNO055 FAQ #4
"Depending on your system setup, you might need to adjust the pullups on the SCL and SDA lines to be a bit stronger. The BNO055 has very tight timing requirements on the I2C bus, requiring short setup and rise times on the signals. By default the breakout board has 10K pullups, which might be too weak on some setups."
-
@fehlfarbe said in Reading BNO055:
oldest firmware available
just change numbers in the link
https://software.pycom.io/downloads/WiPy-1.7.2.b1.tar.gzI see on the BN0055 there are 10k pullup resistors - should be ok because there are shifter on BS138.
-
@livius oldest firmware available at https://forum.pycom.io/topic/517/downgrading-firmware-advanced-users/20 is 1.7.9.b3
Wiring:
The breakout board has 10k pullups on SDA/SCL. I tried a second board but same problem :)
-
I downgraded to WiPy-1.7.9.b3 - no change.
1.7.2.b1
;-)but how looks like your wiring?
Do you have some pullups? Maybe internal puulups on the board BNO055?
-
@robert-hh sometimes it returns the adress of the device
0x28
, sometimes it returns nothing.
-
@livius I downgraded to WiPy-1.7.9.b3 - no change.
-
@fehlfarbe What does i2c.scan() return, after you have initialized the interface?
-
@fehlfarbe
if you really do not need to have recent firmware on Wipy2
then the most stable for me is1.7.2.b1
- try downgrade or upgrade
-
@livius yes, I tried 1000, 100000 and 400000 but it's always the same problem. Once, the device returned at least zero values for temperature and so on and then it raised an I2C bus error.
-
@fehlfarbe
Did you tried with standard baudrate100000
?