I’m trying to setup an I2C communication by I2C between Arduino and Hummingboard Mate but I can’t find any information related with this. I have searched on schematics but I2C3 are connected with several different pins. How can I use I2C ports with smbus python library? Which SMBUS port is used for this? I¡m using this code:
from smbus import SMBus
addr = 8 # bus address
bus = SMBus(3) # indicates /dev/ic2-1
numb = 1
print ("Enter 1 for ON or 0 for OFF")
while numb == 1:
ledstate = input(">>>> ")
if ledstate == "1":
bus.write_byte(addr, 1) # switch it on
elif ledstate == "0":
bus.write_byte(addr, 0) # switch it on
else:
numb = 0
I don’t specifically know the python smbus package, but if the linux device is /dev/i2c-1 then I would assume that you would use SMBus(1) I2C3 is the i2c bus on the SOC, but if other i2c interfaces aren’t used because their pins are used for other purposes then Linux will initialize the devices that are available numerically.
Then you should see that device address if you run i2cdetect -y 2 the NXP devices all start their numbering at 1,2,3,4 etc however Linux enumerates starting at 0. So on the MikroBus header which uses i2c3 the linux device with be /dev/i2c2