Created
October 14, 2023 23:51
-
-
Save mattytrentini/568cfa9aa7a1cda8fcd158a68d765526 to your computer and use it in GitHub Desktop.
i2cdetect in MicroPython
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def i2cdetect(addresses): | |
print(" 0 1 2 3 4 5 6 7 8 9 a b c d e f") | |
for i in range(0x8): | |
print(f"{i*0x10:02x}:", end="") | |
for j in range(0x10): | |
addr = i * 0x10 + j | |
if 0x02 < addr < 0x78: | |
if addr in addresses: | |
print(f" {addr:02x}", end="") | |
else: | |
print(" --", end="") | |
else: | |
print(" ", end="") | |
print("") | |
addrs = [0x30, 0x36, 0x50, 0x52] | |
i2cdetect(addrs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output matches Linux's
i2cdetect
: