Cant get i2c to work on my QT Py RP2040

General project help for Adafruit customers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
alanspurgeon
 
Posts: 9
Joined: Mon Jan 10, 2022 4:26 am

Cant get i2c to work on my QT Py RP2040

Post by alanspurgeon »

Probably a noob issue. I have a SM1107 128x128 mono display, nunchuck board, and of course the QT Py RP2040 board. Using Mu and CircuitPython 7. I got past the bit on making sure the right i2c bus was selected. I was first trying the display demo but it didn't work so I loaded up the i2c scan code and it indicates there is nothing on the bus. Both devices show green power led. It is wired: QT Py -> Nunchuck -> SM1107. Ive tried them separately as well but nothing.

code.py output:
I2C addresses found: []
I2C addresses found: []
I2C addresses found: []
I2C addresses found: []


Code I'm running..


import time
import board

# To create I2C bus on specific pins
import busio
i2c = busio.I2C(board.SCL1, board.SDA1) # QT Py RP2040 STEMMA connector

while not i2c.try_lock():
pass

try:
while True:
print(
"I2C addresses found:",
[hex(device_address) for device_address in i2c.scan()],
)
time.sleep(2)

finally: # unlock the i2c bus when ctrl-c'ing out of the loop
i2c.unlock()


Any suggestions to get me back on track? Thanks.

User avatar
adafruit_support_carter
 
Posts: 29458
Joined: Tue Nov 29, 2016 2:45 pm

Re: Cant get i2c to work on my QT Py RP2040

Post by adafruit_support_carter »

Are you using the STEMMA connector or the header pins on the QT Py?

User avatar
alanspurgeon
 
Posts: 9
Joined: Mon Jan 10, 2022 4:26 am

Re: Cant get i2c to work on my QT Py RP2040

Post by alanspurgeon »

STEMMA connector. Ive tried multiple in case I had a bad one.

User avatar
adafruit_support_carter
 
Posts: 29458
Joined: Tue Nov 29, 2016 2:45 pm

Re: Cant get i2c to work on my QT Py RP2040

Post by adafruit_support_carter »

OK, code looks nominally correct then.
I have a SM1107 128x128 mono display, nunchuck board
What exact products are these? Can you link to product page.


User avatar
adafruit_support_carter
 
Posts: 29458
Joined: Tue Nov 29, 2016 2:45 pm

Re: Cant get i2c to work on my QT Py RP2040

Post by adafruit_support_carter »

Thanks. For the Nunchuk adapter, it's just an adapter. You'll need to attach a Nunchuck to get anything to show up in an I2C scan.

The OLED should work though. I just hooked one up real quick to make sure:

Code: Select all

Adafruit CircuitPython 7.0.0 on 2021-09-20; Adafruit QT Py RP2040 with rp2040
>>> import board
>>> import busio
>>> i2c = busio.I2C(board.SCL1, board.SDA1)
>>> i2c.try_lock()
True
>>> i2c.scan()
[61]
>>> i2c.scan()
[61]
>>> 
It sounds like you've already tried this, but can you try scanning with *just* the OLED attached again.

User avatar
alanspurgeon
 
Posts: 9
Joined: Mon Jan 10, 2022 4:26 am

Re: Cant get i2c to work on my QT Py RP2040

Post by alanspurgeon »

Sure. I added a photo as well in case I've hooked it up wrong or something.
When it is not running code the RP2040 the neopixel flashes red every few seconds. Is that normal?
Also when it is running and I unplug the STEMMA then plug it back in I might get a burst of it finding a dozen devices then settles down to nothing like this..

I2C addresses found: []
I2C addresses found: []
I2C addresses found: []
I2C addresses found: ['0xd', '0xe', '0x10', '0x3a', '0x3d', '0x3f', '0x40', '0x42', '0x43', '0x44', '0x45', '0x49', '0x4a', '0x4b', '0x4c', '0x4d', '0x4e', '0x4f', '0x50', '0x51', '0x52', '0x53', '0x54', '0x55', '0x56', '0x57', '0x58', '0x59', '0x5a', '0x5b', '0x5c', '0x5d', '0x5e', '0x5f', '0x60', '0x61', '0x62', '0x63', '0x64', '0x65', '0x66', '0x67', '0x68', '0x69', '0x6a', '0x6b', '0x6c', '0x6d', '0x6e', '0x6f', '0x70', '0x71', '0x72', '0x73', '0x74', '0x75', '0x76', '0x77']
I2C addresses found: ['0x9', '0xb', '0xc', '0xe', '0xf', '0x10', '0x11', '0x12', '0x13', '0x14', '0x15', '0x16', '0x17', '0x18', '0x19', '0x1a', '0x1b', '0x1c', '0x1d', '0x1e', '0x1f', '0x20', '0x21', '0x22', '0x24', '0x26', '0x27', '0x28', '0x29', '0x2a', '0x2b', '0x2c', '0x2d', '0x30', '0x31', '0x32', '0x33']
I2C addresses found: []


This is what I'm running: "Adafruit CircuitPython 7.1.0 on 2021-12-28; Adafruit QT Py RP2040 with rp2040"
QT Py RP2040.jpg
QT Py RP2040.jpg (69.11 KiB) Viewed 171 times
Last edited by alanspurgeon on Mon Jan 10, 2022 7:38 pm, edited 3 times in total.

User avatar
adafruit_support_carter
 
Posts: 29458
Joined: Tue Nov 29, 2016 2:45 pm

Re: Cant get i2c to work on my QT Py RP2040

Post by adafruit_support_carter »

Thanks for the photo. Weird, that's pretty much what I just set up here and tested.

What version of CircuitPython are you running?

User avatar
alanspurgeon
 
Posts: 9
Joined: Mon Jan 10, 2022 4:26 am

Re: Cant get i2c to work on my QT Py RP2040

Post by alanspurgeon »

Adafruit CircuitPython 7.1.0 on 2021-12-28; Adafruit QT Py RP2040 with rp2040

User avatar
alanspurgeon
 
Posts: 9
Joined: Mon Jan 10, 2022 4:26 am

Re: Cant get i2c to work on my QT Py RP2040

Post by alanspurgeon »

Maybe I hosed the board somehow? I'll order another of both pieces and see if it happens with those.
I just wanted to make sure I was not doing something stupid with the code.

User avatar
alanspurgeon
 
Posts: 9
Joined: Mon Jan 10, 2022 4:26 am

Re: Cant get i2c to work on my QT Py RP2040

Post by alanspurgeon »

Your out of the 128x128 mono so I picked up the grayscale instead.
I'll let you know if the new devices worked.

thanks

User avatar
adafruit_support_carter
 
Posts: 29458
Joined: Tue Nov 29, 2016 2:45 pm

Re: Cant get i2c to work on my QT Py RP2040

Post by adafruit_support_carter »

When it is not running code the RP2040 the neopixel flashes red every few seconds. Is that normal?
That may be one of the status indicator codes?
https://learn.adafruit.com/welcome-to-c ... 2978455-21
Also when it is running and I unplug the STEMMA then plug it back in I might get a burst of it finding a dozen devices then settles down to nothing like this..
I2C is *not* hot swappable. You can't unplug / plug things while powered like you can with USB devices. So you're probably seeing some weird results in the scan because of this.

I just updated to 7.1.0 also, and it still works OK:

Code: Select all

Adafruit CircuitPython 7.1.0 on 2021-12-28; Adafruit QT Py RP2040 with rp2040
>>> import board
>>> import busio
>>> i2c = busio.I2C(board.SCL1, board.SDA1)
>>> i2c.try_lock()
True
>>> i2c.scan()
[61]
>>> 
Maybe try running the scan interactively like I did above? See if that produces any different results.

User avatar
alanspurgeon
 
Posts: 9
Joined: Mon Jan 10, 2022 4:26 am

Re: Cant get i2c to work on my QT Py RP2040

Post by alanspurgeon »

I was wondering if i2c was hot swappable or not, now I know. I was probably watching a youtube video and someone did that so I assumed (my bad) that it was ok. I'll make sure power is off before changing devices on the bus.

"2 red blinks": I thought it might be a status code. I Ctrl-C the running program to end it. That's what it is.

When my order comes in next week I'll give them a try. Thank you for taking so much time to assist me. I'll let you know what I find out.

Alan

User avatar
adafruit_support_carter
 
Posts: 29458
Joined: Tue Nov 29, 2016 2:45 pm

Re: Cant get i2c to work on my QT Py RP2040

Post by adafruit_support_carter »

Yep, you'll see people plugging I2C things in while powered. You can get away with that and depending on what is done in terms of code and soft resets, it is possible to get things working. But in general, it's not how I2C was designed to work.

User avatar
alanspurgeon
 
Posts: 9
Joined: Mon Jan 10, 2022 4:26 am

Re: Cant get i2c to work on my QT Py RP2040

Post by alanspurgeon »

The new QT Py RP2040 arrived along with a ssd1327 128x128 i2c grayscale display.

When I went to install the latest stable release of CircuitPython (adafruit-circuitpython-qtpy_m0-en_US-7.1.1) neither QT Py would install it. The file shows up as only being 371,712 bytes. I can install 7.1.0 fine on both QT Py boards, that version is much bigger in size (1,462,272 bytes). I tried downloading the 7.1.1 multiple times but just keep getting the same result. So I decided to just stick with 7.1.0,

I hooked up the grayscale display to the new QT Py, ran the i2c bus scan and it found it. Great! Okay, so I hooked up the original QT Py, plugged in the grayscale display, ran the same code as on the other QT Py and it works as well. Interesting. I even managed to get some demo code to draw to the display.

What did I learn? Not sure. In the process I did reload 7.1.0 onto the original QT Py so whatever was causing the i2c issue may have been fixed by that.

I'm happy and I like the grayscale display anyway. I'll pick up where I left off.

Thanks for your assistance.

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

Return to “General Project help”