Teensy 4.0 and I2C

hybotics

New member
What would cause an I2C scan to show all addresses being active when there should be no for this to happen? That is what happens when I run my simple I2C bus scanner script on a Teensy 4.0. I have never seen this before.
Code:
# Import all board pins.
from machine import SoftI2C, Pin
from micropython import const

HW_I2C0_SDA                     = const(18)
HW_I2C0_SCL                     = const(19)

HW_I2C1_SDA                     = const(17)
HW_I2C1_SCL                     = const(16)

TP_SDA = Pin(HW_I2C0_SDA)
TP_SCL = Pin(HW_I2C0_SCL)

# Create the I2C interface.
i2c = SoftI2C(sda=TP_SDA, scl=TP_SCL, freq=400000)

print()
print("Simple I2C bus scanner")
print()

scan = i2c.scan()

if scan:
	print("Devices on the I2C bus:")

	for addr in scan:
		print("\tDecimal: {0:3d}, Hex: {1}".format(addr, hex(addr)))
else:
  print("There are no devices on the I2C bus")

print()


8-Dale
 
Last edited:
What would cause an I2C scan to show all addresses being active when there should be no for this to happen? That is what happens when I run my simple I2C bus scanner script on a Teensy 4.0. I have never seen this before.
Code:
# Import all board pins.
from machine import SoftI2C, Pin
from micropython import const

HW_I2C0_SDA                     = const(18)
HW_I2C0_SCL                     = const(19)

HW_I2C1_SDA                     = const(17)
HW_I2C1_SCL                     = const(16)

TP_SDA = Pin(HW_I2C0_SDA)
TP_SCL = Pin(HW_I2C0_SCL)

# Create the I2C interface.
i2c = SoftI2C(sda=TP_SDA, scl=TP_SCL, freq=400000)

print()
print("Simple I2C bus scanner")
print()

scan = i2c.scan()

if scan:
	print("Devices on the I2C bus:")

	for addr in scan:
		print("\tDecimal: {0:3d}, Hex: {1}".format(addr, hex(addr)))
else:
  print("There are no devices on the I2C bus")

print()


8-Dale

Did you post the actual source that you are building & loading into the T4.0 ?? Are you using the Arduino IDE to build ?? What you posted does not build in the Arduino IDE & throws syntax errors on the first line.

I must be missing something obvious . . . I'd like to help, but will need more info to make that possible !!

Mark J Culross
KD5RXT
 
Did you post the actual source that you are building & loading into the T4.0 ?? Are you using the Arduino IDE to build ??
It is Micropython code that runs right on an MCU.

What you posted does not build in the Arduino IDE & throws syntax errors on the first line.
Of course, it does not build in the Arduino IDE. I am surprised that you did not recognize it is not Arduino code.
MicroPython v1.16-236-gb51e7e9d0 on 2021-08-21; Teensy 4.0 with MIMXRT1062DVJ6A

8-Dale
 
It is Micropython code that runs right on an MCU.


MicroPython v1.16-236-gb51e7e9d0 on 2021-08-21; Teensy 4.0 with MIMXRT1062DVJ6A

8-Dale

8-Dale:

I was missing something very obvious !! I have not used MicroPython, so not recognizable as such to me. Sorry (both that I didn't recognize it & that I can't be of any help) !!

Mark J Culross
KD5RXT
 
Back
Top