RuntimeError with Trinket M0

CircuitPython on hardware including Adafruit's boards, and CircuitPython libraries using Blinka on host computers.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
klpauba
 
Posts: 3
Joined: Sun Mar 03, 2019 12:15 pm

RuntimeError with Trinket M0

Post by klpauba »

I'm getting the following error when attempting to create an i2c object:

Code: Select all

 RuntimeError: SDA or SCL needs a pull up
The implicated code is:

Code: Select all

import busio
i2c = busio.I2C(board.SCL, board.SDA)
Does the firmware determine that the pullups are missing and refuse to create the object? Will things work as expected once I attach the sensor and add the pullups?

User avatar
adafruit_support_mike
 
Posts: 67454
Joined: Thu Feb 11, 2010 2:51 pm

Re: RuntimeError with Trinket M0

Post by adafruit_support_mike »

Hrm.. that shouldn't happen. The microcontroller's SDA and SCL pins have built in pull-ups that can be enabled in code.

As a sanity check, try disconnecting any I2C devices from the SDA/SCL pins and see if you get the same error with just the Trinket M0.

User avatar
klpauba
 
Posts: 3
Joined: Sun Mar 03, 2019 12:15 pm

Re: RuntimeError with Trinket M0

Post by klpauba »

I haven't connected any I2C devices yet.

I might have messed things up as I set up the environment on my iMac to recompile the firmware using the instructions on you site. That all worked well but I think that is when I started getting the error (I'm not positive though). I then reloaded the the original firmware back (Adafruit CircuitPython 4.0.0-alpha.5-497-g738e8f0). Problem remains.

How might I enable the pullups in code (I presume I can do this in python, right)?

Thanks for your help, Mike!

User avatar
adafruit_support_mike
 
Posts: 67454
Joined: Thu Feb 11, 2010 2:51 pm

Re: RuntimeError with Trinket M0

Post by adafruit_support_mike »

The busio.I2C code that handles I2C should set the pull-ups on its own.

I'm not as familiar with the low-level details of the CircuitPython environment, so let me copy this thread over to the CircuitPython forum. The folks who moderate there know the code inside and out (because they wrote it).

User avatar
adafruit_support_mike
 
Posts: 67454
Joined: Thu Feb 11, 2010 2:51 pm

Re: RuntimeError with Trinket M0

Post by adafruit_support_mike »

[copied to the CircuitPython forum]

User avatar
jerryn
 
Posts: 1869
Joined: Sat Sep 14, 2013 9:05 am

Re: RuntimeError with Trinket M0

Post by jerryn »

External Pullups are required for the I2C lines with the Trinket M0 . This the error you are seeing is normal if no device is connected.

User avatar
jerryn
 
Posts: 1869
Joined: Sat Sep 14, 2013 9:05 am

Re: RuntimeError with Trinket M0

Post by jerryn »

More information is here:

https://learn.adafruit.com/adafruit-tri ... python-i2c

especially:
Be aware that the Adafruit microcontroller boards do not have I2C pullup resistors built in! All of the Adafruit breakouts do, but if you're building your own board or using a non-Adafruit breakout, you must add 2.2K-10K ohm pullups on both SDA and SCL to the 3.3V.

User avatar
klpauba
 
Posts: 3
Joined: Sun Mar 03, 2019 12:15 pm

Re: RuntimeError with Trinket M0

Post by klpauba »

Thanks! I should have looked closer at the documentation.

Locked
Please be positive and constructive with your questions and comments.

Return to “Adafruit CircuitPython”