Black Lives Matter - Action and Equality. ... Adafruit is open and shipping.
0

I/O Error when using LIS3DH and TCA9548a, M4 Feather Express
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

I/O Error when using LIS3DH and TCA9548a, M4 Feather Express

by jacksonlamb on Mon Mar 30, 2020 4:15 am

I am using an M4 Feather Express board with Adafruit CircuitPython version 4.1.2, TCA9548a with the 4.x library, and 4 LIS3DH sensors using their 4.x library. I soldered 4.7k resistors to the SCA and SDA pins on the TCA board after my code would unreliably fail due to an SDA/SCA pullup resistor error. Now that error does not occur, but the code cannot initialize i2c connections to the accelerometers without giving this error:

Code: Select all | TOGGLE FULL SIZE
code.py output:
Initialized I2C Connection
Imported TCA9548A
Traceback (most recent call last):
  File "code.py", line 35, in <module>
  File "adafruit_lis3dh.py", line 319, in __init__
  File "adafruit_bus_device/i2c_device.py", line 68, in __init__
  File "adafruit_bus_device/i2c_device.py", line 166, in __probe_for_device
  File "adafruit_tca9548a.py", line 65, in try_lock
OSError: [Errno 5] Input/output error


I understand that input/output errors are typically caused by poor wiring, however all continuity checks are good. The LIS3DH breakout boards are supposed to have built in pull down resistors, however I added 4.7k resistors to the i2c wires for one accelerometer to see if the results were different. All accelerometers give the same error as shown above.
My code (the part where the errors are occurring) is as follows. I am using Mu editor.

Code: Select all | TOGGLE FULL SIZE
import board
import digitalio
import busio
import pulseio
import time
import math
import random
import adafruit_lis3dh
import adafruit_tca9548a
import struct

# On Board LED Initialization
led = digitalio.DigitalInOut(board.D13)
led.direction = digitalio.Direction.OUTPUT

# Bluetooth Initialization
uart = busio.UART(board.TX, board.RX, baudrate=9600)

# I2C Channel Initialization
i2c = busio.I2C(board.SCL, board.SDA)
print('Initialized I2C Connection')
tca = adafruit_tca9548a.TCA9548A(i2c)
print('Imported TCA9548A')
time.sleep(0.5)
lis1 = adafruit_lis3dh.LIS3DH_I2C(tca[2])
print('Imported LIS3DH 1')
time.sleep(0.5)
lis2 = adafruit_lis3dh.LIS3DH_I2C(tca[3])
print('Imported LIS3DH 2')
time.sleep(0.5)
lis3 = adafruit_lis3dh.LIS3DH_I2C(tca[4])
print('Imported LIS3DH 3')
time.sleep(0.5)
lis4 = adafruit_lis3dh.LIS3DH_I2C(tca[5])
print('Imported LIS3DH 4')

jacksonlamb
 
Posts: 1
Joined: Mon Mar 30, 2020 4:03 am

Re: I/O Error when using LIS3DH and TCA9548a, M4 Feather Exp

by adafruit_support_carter on Mon Mar 30, 2020 5:57 pm

I2C uses pull up resistors, not pull down. And if you are using the LIS3DH breakout:
https://www.adafruit.com/product/2809
the resistors are included on the breakout and you don't need to add any additional resistors.

Can you post a photo of your setup showing how everything is connected.

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

Please be positive and constructive with your questions and comments.