Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I2C I/O Error on Teensy 4.1 #118

Open
jksjaz opened this issue Sep 9, 2023 · 0 comments
Open

I2C I/O Error on Teensy 4.1 #118

jksjaz opened this issue Sep 9, 2023 · 0 comments

Comments

@jksjaz
Copy link

jksjaz commented Sep 9, 2023

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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant