Page 1 of 1

NUCLEO-L476RG - using I2C

Posted: Sun Oct 24, 2021 7:19 pm
by tnkumar
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?

Re: NUCLEO-L476RG - using I2C

Posted: Mon Oct 25, 2021 6:32 am
by Roberthh
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.