0

SDA or SCL needs a pull up
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

SDA or SCL needs a pull up

by geekguy on Sun Sep 08, 2019 7:51 pm

Hi,

I have a Feather M0 Express connected to a TCA9548A I2C Multiplexer.

Does the TCA9548a have I2C pull ups like most of the Adafruit breakout boards have? If so, I am getting this:
Code: Select all | TOGGLE FULL SIZE
Traceback (most recent call last):
  File "main.py", line 11, in <module>
RuntimeError: SDA or SCL needs a pull up
My code is, which usually runs on a Feather M4 Express:
Code: Select all | TOGGLE FULL SIZE
# This example shows using two TSL2491 light sensors attached to TCA9548A channels 0 and 1.
# Use with other I2C sensors would be similar.
import board
import busio
import time
import adafruit_tca9548a
import adafruit_tsl2591
import adafruit_vl53l0x

# Create I2C bus as normal
i2c = busio.I2C(board.SCL, board.SDA)

# Create the TCA9548A object and give it the I2C bus
tca = adafruit_tca9548a.TCA9548A(i2c)

# For each sensor, create it using the TCA9548A channel instead of the I2C object
tsl = adafruit_tsl2591.TSL2591(tca[0])
vl53 = adafruit_vl53l0x.VL53L0X(tca[1])

# After initial setup, can just use sensors as normal.
while True:
    print(tsl.lux, vl53.range)
    time.sleep(0.5)
What is wrong? I have checked my wiring, and everything looks good to me.

8-Dale
Attachments
Feather_M0_TCA9548a._1024x768.jpg
Feather_M0_TCA9548a._1024x768.jpg (746.28 KiB) Viewed 268 times

geekguy
 
Posts: 246
Joined: Tue Sep 10, 2013 2:43 pm
Location: Beaverton, OR

Re: SDA or SCL needs a pull up

by mikeysklar on Sun Sep 08, 2019 9:08 pm

Hello geekguy,

The TCA9548a does include pull up resistors.

Since the soldering looks a little suspicious on the TCA9548a maybe you could pull it from the breadboard?

How about starting with each sensor one at a time connected to your device directly using these wiring and coding examples.

https://learn.adafruit.com/adafruit-tsl ... cuitpython

https://learn.adafruit.com/adafruit-vl5 ... cuitpython

mikeysklar
 
Posts: 177
Joined: Mon Aug 01, 2016 8:10 pm

Re: SDA or SCL needs a pull up

by geekguy on Sun Sep 08, 2019 10:59 pm

mikeysklar wrote:Hello geekguy,

The TCA9548a does include pull up resistors.

Since the soldering looks a little suspicious on the TCA9548a maybe you could pull it from the breadboard?

The TCA9548a is the only thing connected to the Feather. I can easily disconnect though.

8-Dale

geekguy
 
Posts: 246
Joined: Tue Sep 10, 2013 2:43 pm
Location: Beaverton, OR

Re: SDA or SCL needs a pull up

by geekguy on Tue Sep 10, 2019 3:40 pm

mikeysklar wrote:Hello geekguy,

The TCA9548a does include pull up resistors.

Since the soldering looks a little suspicious on the TCA9548a maybe you could pull it from the breadboard?

I connected each of the TSL2561 and VL53L0X directly to an ItsyBitsy M4 (one at a time, because they have the same unchangeable I2C address. They each work perfection when directly connected, but not when connected through the TCA9548a. I aso replaced the TCA9548a with another one and got the same results.

Code: Select all | TOGGLE FULL SIZE
Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.
main.py output:
Traceback (most recent call last):
  File "main.py", line 19, in <module>
  File "adafruit_vl53l0x.py", line 156, in __init__
  File "adafruit_bus_device/i2c_device.py", line 66, in __init__
  File "adafruit_tca9548a.py", line 65, in try_lock
OSError: [Errno 5] Input/output error
My Circuitpython test code:
Code: Select all | TOGGLE FULL SIZE
# This example shows using two TSL2491 light sensors attached to TCA9548A channels 0 and 1.
# Use with other I2C sensors would be similar.
import board
import busio
import time
import adafruit_tca9548a
import adafruit_tsl2591
import adafruit_vl53l0x

# Create I2C bus as normal
i2c = busio.I2C(board.SCL, board.SDA)

# Create the TCA9548A object and give it the I2C bus
tca9548a = adafruit_tca9548a.TCA9548A(i2c)

# For each sensor, create it using the TCA9548A channel instead of the I2C object
###tsl2591 = adafruit_tsl2591.TSL2591(tca9548a[0])
###tsl2591 = adafruit_tsl2591.TSL2591(i2c)
vl53l0x = adafruit_vl53l0x.VL53L0X(tca9548a[1])
###vl53l0x = adafruit_vl53l0x.VL53L0X(i2c)

# After initial setup, can just use sensors as normal.
while True:
    ###print("Lux = {0:3.1f}".format(tsl2591.lux))
    print("Range = {0:4d} mm".format(vl53l0x.range))
    time.sleep(2)
I buy multiples of new sensors when I buy them, just in case. I think there may be a problem with the adafruit_tca9548a library.

8-Dale
Attachments
ItsyBitsy_M4_tca9548a_vl53l0x_1024x768.jpg
ItsyBitsy_M4_tca9548a_vl53l0x_1024x768.jpg (822.03 KiB) Viewed 210 times

geekguy
 
Posts: 246
Joined: Tue Sep 10, 2013 2:43 pm
Location: Beaverton, OR

Re: SDA or SCL needs a pull up

by mikeysklar on Tue Sep 10, 2019 4:30 pm

@geekyguy,

Thank you for testing the sensors individually and localizing the issue around the tca9548a library.

I see you switched over to the ItsyBitsy M4 for the latest configuration. What version CircuitPython and which CircuitPython Library bundle are you using?

The next thing I'd like to see you try is to remove the vl53l0x, but leave the tca9548a and tsl2591 wired in.

I'm a little suspicious of a slow speed i2c bus issue on the vl5310x which might be causing the pull up error.

mikeysklar
 
Posts: 177
Joined: Mon Aug 01, 2016 8:10 pm

Re: SDA or SCL needs a pull up

by geekguy on Tue Sep 10, 2019 5:01 pm

mikeysklar wrote:@geekyguy,

Thank you for testing the sensors individually and localizing the issue around the tca9548a library.

I just want to give back to a community that has given me so much, and get help in the process.

mikeysklar wrote:I see you switched over to the ItsyBitsy M4 for the latest configuration. What version CircuitPython and which CircuitPython Library bundle are you using?

Circuitpython v4.1.0 with the Library Bundle adafruit-circuitpython-bundle-4.x-mpy-20190828, which I just upgraded to adafruit-circuitpython-bundle-4.x-mpy-20190910.

The results are the same with the same circuit and code.

mikeysklar wrote:The next thing I'd like to see you try is to remove the vl53l0x, but leave the tca9548a and tsl2591 wired in.

I have already done all permutations of the TSL2591 and VL53L0X direct connection and through the TCA9548a. Only the direct connections work.

8-Dale

geekguy
 
Posts: 246
Joined: Tue Sep 10, 2013 2:43 pm
Location: Beaverton, OR

Re: SDA or SCL needs a pull up

by mikeysklar on Tue Sep 10, 2019 5:16 pm

I'm still a little suspicious about speed with if you don't mind trying the "normal speed" of 100k (as opposed to 400k which is the default full speed) it would help rule out that issue. You can do it in software. Simply changing the following line from this:

Code: Select all | TOGGLE FULL SIZE
i2c = busio.I2C(board.SCL, board.SDA)

to this:

Code: Select all | TOGGLE FULL SIZE
i2c = busio.I2C(board.SCL, board.SDA, frequency=100000)

mikeysklar
 
Posts: 177
Joined: Mon Aug 01, 2016 8:10 pm

Re: SDA or SCL needs a pull up

by geekguy on Tue Sep 10, 2019 11:03 pm

mikeysklar wrote:Simply changing the following line from this:

Code: Select all | TOGGLE FULL SIZE
i2c = busio.I2C(board.SCL, board.SDA)

to this:

Code: Select all | TOGGLE FULL SIZE
i2c = busio.I2C(board.SCL, board.SDA, frequency=100000)

Done.

Results are the same.

8-Dale

geekguy
 
Posts: 246
Joined: Tue Sep 10, 2013 2:43 pm
Location: Beaverton, OR

Re: SDA or SCL needs a pull up

by adafruit_support_carter on Wed Sep 11, 2019 6:53 pm

Please post a photo showing the soldering job on the headers pins on the back side of the Feather.

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

Re: SDA or SCL needs a pull up

by geekguy on Wed Sep 11, 2019 8:33 pm

adafruit_support_carter wrote:Please post a photo showing the soldering job on the headers pins on the back side of the Feather.

I am running that circuit with an ItsyBitsy M4 now. The results are the same as with the Feather M4 Express. Do you want a picture of the back of the ItsyBitsy?

8-Dale

geekguy
 
Posts: 246
Joined: Tue Sep 10, 2013 2:43 pm
Location: Beaverton, OR

Re: SDA or SCL needs a pull up

by adafruit_support_carter on Wed Sep 11, 2019 8:51 pm

Yes please. Just to make sure.

Also, the error seems to have changed? You were getting I2C pull up errors with the Feather:
Code: Select all | TOGGLE FULL SIZE
RuntimeError: SDA or SCL needs a pull up

Now you are getting IO errors:
Code: Select all | TOGGLE FULL SIZE
OSError: [Errno 5] Input/output error

Is that correct?

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

Re: SDA or SCL needs a pull up

by geekguy on Wed Sep 11, 2019 10:03 pm

adafruit_support_carter wrote:Yes please. Just to make sure.

Also, the error seems to have changed? You were getting I2C pull up errors with the Feather:
Code: Select all | TOGGLE FULL SIZE
RuntimeError: SDA or SCL needs a pull up

Now you are getting IO errors:
Code: Select all | TOGGLE FULL SIZE
OSError: [Errno 5] Input/output error

Is that correct?

Yes.

8-Dale
Attachments
ItsyBtsy_M4_Underside_1024x768.jpg
ItsyBtsy_M4_Underside_1024x768.jpg (669.08 KiB) Viewed 140 times

geekguy
 
Posts: 246
Joined: Tue Sep 10, 2013 2:43 pm
Location: Beaverton, OR

Re: SDA or SCL needs a pull up

by adafruit_support_carter on Thu Sep 12, 2019 11:11 am

A little hard to tell for sure. But let's try a simple scan test to make sure the TCA is being seen properly. Setup the Itsy M4 again and wire it up to only the TCA. Then try running this:
Code: Select all | TOGGLE FULL SIZE
import board
i2c = board.I2C()
i2c.try_lock()
i2c.scan()


Since it's so short, you can just run it via REPL:
Code: Select all | TOGGLE FULL SIZE
Adafruit CircuitPython 4.1.0 on 2019-08-02; Adafruit ItsyBitsy M4 Express with samd51g19
>>> import board
>>> i2c = board.I2C()
>>> i2c.try_lock()
True
>>> i2c.scan()
[112]
>>>


Post the results you get from running the scan.

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

Re: SDA or SCL needs a pull up

by geekguy on Thu Sep 12, 2019 12:47 pm

adafruit_support_carter wrote:A little hard to tell for sure. But let's try a simple scan test to make sure the TCA is being seen properly. Setup the Itsy M4 again and wire it up to only the TCA. Then try running this:
Code: Select all | TOGGLE FULL SIZE
import board
i2c = board.I2C()
i2c.try_lock()
i2c.scan()

Here are my results. I have the TCA9548a at address 0x77.
Code: Select all | TOGGLE FULL SIZE
Press any key to enter the REPL. Use CTRL-D to reload.
Adafruit CircuitPython 4.1.0 on 2019-08-02; Adafruit ItsyBitsy M4 Express with samd51g19
>>> import board
>>> i2c = board.I2C()
>>> i2c.try_lock()
True
>>> scan = i2c.scan()
>>> for addr in scan:
...     print("Adress = {0:3d}, Hex = {1}".format(addr, hex(addr)))
...     
...     
...
Adress = 119, Hex = 0x77
>>>
8-Dale

geekguy
 
Posts: 246
Joined: Tue Sep 10, 2013 2:43 pm
Location: Beaverton, OR

Re: SDA or SCL needs a pull up

by geekguy on Thu Sep 12, 2019 12:48 pm

adafruit_support_carter wrote:A little hard to tell for sure. But let's try a simple scan test to make sure the TCA is being seen properly. Setup the Itsy M4 again and wire it up to only the TCA. Then try running this:
Code: Select all | TOGGLE FULL SIZE
import board
i2c = board.I2C()
i2c.try_lock()
i2c.scan()

Here are my results. I have the TCA9548a at address 0x77.
Code: Select all | TOGGLE FULL SIZE
Press any key to enter the REPL. Use CTRL-D to reload.
Adafruit CircuitPython 4.1.0 on 2019-08-02; Adafruit ItsyBitsy M4 Express with samd51g19
>>> import board
>>> i2c = board.I2C()
>>> i2c.try_lock()
True
>>> scan = i2c.scan()
>>> for addr in scan:
...     print("Adress = {0:3d}, Hex = {1}".format(addr, hex(addr)))
...     
...     
...
Adress = 119, Hex = 0x77
>>>
8-Dale

geekguy
 
Posts: 246
Joined: Tue Sep 10, 2013 2:43 pm
Location: Beaverton, OR

Please be positive and constructive with your questions and comments.