1
\$\begingroup\$

I'm going to use I2C for Arduino-Raspberry Pi 4 communications, I'm trying to change I2C pins because I need the initial I2C pins (GPIO3 and GPIO4) for other purpose.

I'm using Ubuntu 21.04, and I'm trying this changing config.txt and I'm using SMBUS2.

Here it is my config.txt i2c configuration:

dtparam=audio=on dtparam=i2c_arm=on dtoverlay=i2c-gpio,bus=4,i2c_gpio_delay_us=1,i2c_gpio_sda=23,i2c_gpio_scl=24 dtoverlay=i2c-gpio,bus=3,i2c_gpio_delay_us=1,i2c_gpio_sda=17,i2c_gpio_scl=27 dtparam=spi=on 

My output applying i2cdetect 3 bus using address 31 (with I2C lines located on GPIO17 and GPIO27), is this (is detected correctly):

sudo i2cdetect -y 3 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 1f 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- -- 

But the output code when I execute one smbus2 library test returns an error:

File "/usr/lib/python3/dist-packages/smbus2/smbus2.py", line 643, in write_i2c_block_data ioctl(self.fd, I2C_SMBUS, msg) OSError: [Errno 121] Remote I/O error 

If I connect the I2C lines on GPIO2 and GPIO3 it works.

I'm using a level shifter between Arduino and Raspberry, and 10k pull up resistors to 5V.

\$\endgroup\$
5
  • \$\begingroup\$ In other words, check physical level. Check for continuity and voltage levels when idle (on BOTH sides) \$\endgroup\$ Commented Feb 16, 2022 at 15:18
  • \$\begingroup\$ Yes, I have searched the error but the problem is with i2cdetect the device is detected on the address where it is configured. The same hardware setup works on GPIO2 and GPIO3 (I2C lines by default). \$\endgroup\$ Commented Feb 16, 2022 at 15:23
  • \$\begingroup\$ Did it detect on new GPIO pins? \$\endgroup\$ Commented Feb 16, 2022 at 15:24
  • \$\begingroup\$ Yes, they are detected. I have measured both voltage levels, GPIO2 and GPIO3 are 3.5V and 3V, and GPIO17 and GPIO27 shows 3.8V (both pins) on idle state. \$\endgroup\$ Commented Feb 16, 2022 at 15:27
  • 1
    \$\begingroup\$ @Ilya I have found the problem. It was on the SMBus(X) declaration, I didn't change the X value and I was using other i2c ports. \$\endgroup\$ Commented Feb 17, 2022 at 8:14

1 Answer 1

1
\$\begingroup\$

Problem detected. On SMBus2 library we need to declare the bus. The number X of SMBus(X) is the number of the i2c port. I was using SMBus(1) (the library example), but I was declaring on DToverlays other i2c ports and using them.

bus = smbus.SMBus(4) 
\$\endgroup\$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.