0

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

Please be positive and constructive with your questions and comments.

MagTag RuntimeError: SDA or SCL needs a pull up

by ReneLx on Wed Jan 13, 2021 5:47 pm

Hello,

I already asked this on reddit because i coudn't post here two days ago but there noone could help me so maybe you can help me here.

I just got the MagTag with an AHT20 Sensor and an ST25DV16 that I want to use in my project. At first I wanted to find these two chips via I2C to check the connection but when I want to use I2C over StemmaQT I get the error message "RuntimeError: SDA or SCL needs a pull up". I connected the chips via the StemmaQT connector cables from adafruit and I didn't tested both at the same time.

When i only want to detect the LIS3DH accelerometer on the board without using the StemmaQT it works and i also tested the LIS3DH accelerometer with the simple example and it communicates fine.

I also checked the soldered 10k Pull Ups on the board and the connection to the sensors and they are fine too.

So why do I get that error?

This is the Code I used to detect the devices

Code: Select all | TOGGLE FULL SIZE
# CircuitPython Demo - I2C sensor

import time
import board

i2c = board.I2C()

# Lock the I2C device before we try to scan
while not i2c.try_lock():
    pass
# Print the addresses found once
print("I2C addresses found:", [hex(device_address)
                               for device_address in i2c.scan()])

# Unlock I2C now that we're done scanning.
i2c.unlock()


The Board library also uses the busio library according to the documentation. But I also tried to use the busio library directly and got the same error.

I used this code for busio:
Code: Select all | TOGGLE FULL SIZE
import busio
from board import *

i2c = busio.I2C(SCL, SDA)
print(i2c.scan())
i2c.deinit()

ReneLx
 
Posts: 3
Joined: Sun Jan 10, 2021 12:30 pm

Re: MagTag RuntimeError: SDA or SCL needs a pull up

by adafruit_support_carter on Wed Jan 13, 2021 6:07 pm

Just to be sure of the behavior - with nothing attached to the MagTag's STEMMA connector, the I2C scan shows the LIS3DH OK? But as soon as you attach *either* of the AHT20 or ST25DV16 to the STEMMA connector, you get the error message?

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

Re: MagTag RuntimeError: SDA or SCL needs a pull up

by ReneLx on Wed Jan 13, 2021 6:35 pm

That is correct, yes. Even when i connect the Stemma connector while it is scanning and seeing the LIS3DH at 0x19 the error appears. And also when i power off the MagTag and then connect one of the sensors and then power on the MagTag.

Edit: I just found my Problem. For the StemmaQT Connector I used a JST cable from ebay because yours where out of stock. That cable has a Point to Point connection but I think the Stemma cables need an inverted connection between the pins, right? Well I just checked the connection with the Eagle Board files and found out that the connections isn't correct.

ReneLx
 
Posts: 3
Joined: Sun Jan 10, 2021 12:30 pm

Re: MagTag RuntimeError: SDA or SCL needs a pull up

by adafruit_support_carter on Wed Jan 13, 2021 8:43 pm

The cable should be point to point. It's just the standard I2C pins plus power:

* 3V (or 5V)
* GND
* SCL
* SDA

And in I2C you connect SCL to SCL and SDA to SDA. There's no crossover.

But maybe something else is up with the cable?

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

Re: MagTag RuntimeError: SDA or SCL needs a pull up

by ReneLx on Thu Jan 14, 2021 3:29 am

No the cables are okay but one of the connectors on the cable needs to be rotated by 180°. That was what I meant with the cable need to be not point to point. English is not my first language, sorry.

The connection needs to be like this:

Pin MagTag -> Pin Sensor
1 3V -> 3V 4
2 GND -> GND 3
3 SCL -> SCL 2
4 SDA -> SDA 1

ReneLx
 
Posts: 3
Joined: Sun Jan 10, 2021 12:30 pm

Re: MagTag RuntimeError: SDA or SCL needs a pull up

by adafruit_support_carter on Thu Jan 14, 2021 12:23 pm

Oh, OK. I see what you mean now about the cable. Thanks.

Yes, the wiring above is correct. Sounds like you've figured out a way to rotate one end of the cable and get it to mate up. Hopefully that will work for now. It looks like at least some of the lengths of Adafruit STEMMA QT cables are currently in stock:
https://www.adafruit.com/category/1005

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

Please be positive and constructive with your questions and comments.