NUCLEO-L476RG - using I2C

Discussion and questions about boards that can run MicroPython but don't have a dedicated forum.
Target audience: Everyone interested in running MicroPython on other hardware.
Post Reply
tnkumar
Posts: 1
Joined: Sun Oct 24, 2021 6:57 pm

NUCLEO-L476RG - using I2C

Post by tnkumar » Sun Oct 24, 2021 7:19 pm

from machine import Pin
led=pyb.LED(1)
i2c=pyb.I2C(1)
i2c=machine.SoftI2C(scl=pyb.Pin('PB8'),sda=pyb.Pin('PB9'),freq=100000)
print(i2c.scan())
while True:
led.on()
pyb.delay(100)
led.off()
pyb.delay(100)

I am trying to run the above program. I am not getting any error. But print (i2c.scan()) is printing
[] and not detecting any error

I have connected blue of OLE to SCL/D15, yellow to SDA/D14 and black and red to GND and 3.3V
Any suggestions on what may be wrong?

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: NUCLEO-L476RG - using I2C

Post by Roberthh » Mon Oct 25, 2021 6:32 am

You need just one of the i2c=... statements. If i2c.,scan() returns an empty list, then theer is in most of the cases an communication error. Check the wiring.

Post Reply