adafruit / Adafruit_CircuitPython_BNO055

CircuitPython driver for BNO055 absolute orientation sensor
MIT License
85 stars 51 forks source link

I2C I/O Error on Teensy 4.1 #118

Open jksjaz opened 10 months ago

jksjaz commented 10 months ago

While testing the Adafruit BNO055 sensor connected using STEMMA QT to a Teensy 4.1 with IMXRT1062DVJ6A running Adafruit CircuitPython 8.2.3 on 2023-08-11, I encountered the following error which seems to be an issue with I2C protocol.

code.py output:
Temperature: 0 degrees C
Accelerometer (m/s^2): (0.0, 0.0, 0.0)
Magnetometer (microteslas): (10.0625, 13.75, -39.375)
Gyroscope (rad/sec): (-0.00109083, 0.00218166, -0.00218166)
Euler angle: (0.0, 0.0, 0.0)
Quaternion: (0.0, 0.0, 0.0, 0.0)
Linear acceleration (m/s^2): (0.0, 0.0, 0.0)
Gravity (m/s^2): (0.0, 0.0, 0.0)

Temperature: 28 degrees C
Traceback (most recent call last):
  File "code.py", line 291, in <module>
  File "adafruit_bno055.py", line 416, in acceleration
  File "adafruit_bno055.py", line 155, in __get__
  File "adafruit_register/i2c_struct.py", line 49, in __get__
OSError: [Errno 5] Input/output error

Code sample used:

import adafruit_bno055
import busio

# Initialize the IMU imu_sensor
imu_i2c = busio.I2C(board.SCL, board.SDA)
imu_sensor = adafruit_bno055.BNO055_I2C(imu_i2c)

last_val = 0xFFFF

def temperature():
    global last_val  # pylint: disable=global-statement
    result = imu_sensor.temperature
    if abs(result - last_val) == 128:
        result = imu_sensor.temperature
        if abs(result - last_val) == 128:
            return 0b00111111 & result
    last_val = result
    return result

while True:
    print("Temperature: {} degrees C".format(imu_sensor.temperature))
    """
    print(
        "Temperature: {} degrees C".format(temperature())
    )  # Uncomment if using a Raspberry Pi
    """
    print("Accelerometer (m/s^2): {}".format(imu_sensor.acceleration))
    print("Magnetometer (microteslas): {}".format(imu_sensor.magnetic))
    print("Gyroscope (rad/sec): {}".format(imu_sensor.gyro))
    print("Euler angle: {}".format(imu_sensor.euler))
    print("Quaternion: {}".format(imu_sensor.quaternion))
    print("Linear acceleration (m/s^2): {}".format(imu_sensor.linear_acceleration))
    print("Gravity (m/s^2): {}".format(imu_sensor.gravity))
    print()

    time.sleep(1)