QtPy ESP32-S2 as I2C target

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
zjk
 
Posts: 5
Joined: Fri Mar 10, 2023 9:04 pm

QtPy ESP32-S2 as I2C target

Post by zjk »

I've been trying to set up a system with one QtPy board as the controller, and several more QtPy boards as targets via the PCA9548 STEMMA multiplexer. Using the example code for the i2ctarget library I run into the following problem/s:
  • On the target side, when polling I2CTarget.request, it always returns with request.is_read=True, request.is_restart=False, and request.address={whatever address I started the object with}. This behaviour occurs regardless of the behaviour of the controller, and persists while the board is disconnected from the multiplexer/controller.
Has anyone here got experience setting up one of these boards as an i2c target? Should I use busio instead? I didn't see a way to set up a target with that library but I'd be happy to know if I missed something.

Thanks!

User avatar
mikeysklar
 
Posts: 13824
Joined: Mon Aug 01, 2016 8:10 pm

Re: QtPy ESP32-S2 as I2C target

Post by mikeysklar »

Take a look at these two closed i2ctarget issues. They have some sample code that claims to work and is minimal compared to the example code.

Code: Select all

import board
from i2ctarget import I2CTarget

target = I2CTarget(board.SCL, board.SDA, [0x41])

while True:
    request = target.request()
    if request is not None:
        if request.is_read:
            print("Write request ")
            request.write(b'B')
        else:
            r = request.read()
            if r == "T":
                print("Read a T")
https://github.com/adafruit/circuitpython/issues/6792

https://github.com/adafruit/circuitpython/issues/7241

User avatar
zjk
 
Posts: 5
Joined: Fri Mar 10, 2023 9:04 pm

Re: QtPy ESP32-S2 as I2C target

Post by zjk »

Thanks for the pointer, I'm still experiencing the same behaviour using that example code. The request always comes back as though a write was requested, regardless of what request was sent, or even if nothing is connected to the QtPy in the first place.

Fortunately the STEMMA pins can be used for UART so I'm proceeding with that.

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

Return to “Adafruit CircuitPython”