Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESP32- S2 - i2c scan returns multiple bogus addresses #9931

Closed
T-Mosher opened this issue Jan 3, 2025 · 6 comments · Fixed by #9942
Closed

ESP32- S2 - i2c scan returns multiple bogus addresses #9931

T-Mosher opened this issue Jan 3, 2025 · 6 comments · Fixed by #9942
Assignees
Milestone

Comments

@T-Mosher
Copy link

T-Mosher commented Jan 3, 2025

CircuitPython version

Adafruit CircuitPython 9.2.1 on 2024-11-20; Adafruit Feather ESP32-S2 Reverse TFT with ESP32S2
Board ID:adafruit_feather_esp32s2_reverse_tft

Code/REPL

# SPDX-FileCopyrightText: 2021 Kattni Rembor for Adafruit Industries
# SPDX-License-Identifier: MIT
"""CircuitPython I2C Device Address Scan"""
import time
import board

#i2c = board.I2C()  # uses board.SCL and board.SDA
# Note; it's the same interface, but turns on the STEMMA QT port power
i2c = board.STEMMA_I2C()  # For using the built-in STEMMA QT connector on a microcontroller

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()

Behavior

Testing just the ESP32-S2 Reverse TFT Feather (no additional Feather boards connected, nothing on the Stemma_QT port), the I2C scan returns many incorrect I2C addresses.

i2c_scan_2

In this configuration, the only I2C address that should appear is for the built-in MAX17048 battery gauge on [0x36].

Description

Does not matter whether the i2c_scan uses board.I2C() or board.STEMMA_I2C().
Does not matter whether a LiPo battery is connected to the Feather.
Does not matter whether any other Feather modules are stacked with the ESP32-S2 Feather.
All of these variants result in the same issue: bogus addresses being detected.

Additional information

See this Forum thread for complete details (including investigation by "mikeysklar").
https://forums.adafruit.com/viewtopic.php?t=215740

The Forum thread has a lot of pictures showing a stack of Feathers attached to the ESP32-S2, but that doesn't matter. The issue happens even with no additional boards installed.

The investigation by mikeysklar shows that the issue happens on the ESP32-S2 Reverse TFT, but not on the ESP32-S3 Reverse TFT.

@T-Mosher T-Mosher added the bug label Jan 3, 2025
@jposada202020
Copy link

The problem also appears in the feather TFT ESP32-S2
tested in Adafruit CircuitPython 9.2.1 on 2024-11-20; Adafruit Feather ESP32-S2 TFT with ESP32S2


>>> import ms
I2C addresses found: ['0xb', '0x2b', '0x36', '0x3f', '0x65']
I2C addresses found: ['0x9', '0xf', '0x18', '0x5f', '0x6b']
I2C addresses found: ['0x9', '0x12', '0x2a', '0x5f']
I2C addresses found: ['0x9', '0x14', '0x15', '0x5f', '0x6e', '0x77']
I2C addresses found: ['0x9', '0x14', '0x18', '0x5e', '0x66']
I2C addresses found: ['0x9', '0x16', '0x1b', '0x3a', '0x60', '0x73']
I2C addresses found: ['0x9', '0xe', '0x1f', '0x2b', '0x34', '0x61']

@mikeysklar
Copy link

mikeysklar commented Jan 3, 2025

Adafruit Feather ESP32-S2 Rev TFT i2c scan tests with recent releases of CircuitPython.

+---------+-----------------+
| Version | Result          |
+---------+-----------------+
| 9.2.1   | ghost addresses |
| 9.1.4   | no devices      |
| 9.1.3   | no devices      |
| 9.1.0   | no devices      |
| 9.0.5   | works           |
| 8.2.10  | works           |
+---------+-----------------+

Based on the CP 9.1.0 release notes the ESP-IDF was updated to v5.2.2.

@tannewt tannewt added this to the 9.2.x milestone Jan 3, 2025
@tannewt tannewt added the busio label Jan 3, 2025
@dhalbert
Copy link
Collaborator

dhalbert commented Jan 8, 2025

This is probably because of #9671, which switched to using the ESP-IDF routine i2c_master_probe() to probe for devices. Previously we were doing the probing "manually", and that caused #9535 and #9561. I will see if some adjustment can be made.

@dhalbert dhalbert changed the title ESP32- S2 Reverse TFT Feather - i2c scan returns multiple bogus addresses ESP32- S2 - i2c scan returns multiple bogus addresses Jan 8, 2025
@dhalbert dhalbert self-assigned this Jan 8, 2025
@dhalbert
Copy link
Collaborator

dhalbert commented Jan 8, 2025

I think I have a fix for this via #9942. If you want to test an artifact: https://github.com/adafruit/circuitpython/actions/runs/12679605089

@mikeysklar
Copy link

Thx dan. Looks like you got it. I tried with your current artifact on a ESP32-S2 REV TFT. Looks good picking up the local I2C battery monitor and a MCP23008 board I plugged in.

Adafruit CircuitPython 9.2.1-58-g9251aee706 on 2025-01-08; Adafruit Feather ESP32-S2 Reverse TFT with ESP32S2
>>>
soft reboot

Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.
code.py output:
Checking board.I2C()...ADDED.
Checking board.STEMMA_I2C()...ADDED.
Checking busio.I2C(board.GP1, board.GP0)...SKIPPED: 'module' object has no attribute 'GP1'
----------------------------------------
I2C SCAN
----------------------------------------
board.I2C() addresses found: ['0x20', '0x36']
board.STEMMA_I2C() addresses found: ['0x20', '0x36']
board.I2C() addresses found: ['0x20', '0x36']

@T-Mosher
Copy link
Author

T-Mosher commented Jan 9, 2025

I tried the patched build on my stacked set of Feather boards, it worked fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants