Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 3838

Troubleshooting • Using multiple i2c busses on raspberry pi 5

$
0
0
I have a setup working on my old pi2 B, I am attempting to move my python code and modify where necessary to a pi5. I am hoping to achieve smother less clunky performance and incorporate several new GUI (Tkinter ) features. I have managed to adequately adapt my previous python code to run the Tkinter , hardware PWM on 2 independent pins, gpio input/output control of a couple of stepper motor controllers. I have been searching online forums and tutorials but have failed to establish a method to accomplish using multiple i2c ports on the pi 5. My setup requires 2 i2c port as I am making use of 2 ic2 modules that have the same address. I have built a bit of test code and attempted to run it on both the model 2B and the model 5, in both cases the python is running from a venv folder.

I can establish a i2c connection from/to 2 independent ports on my pi2.
I can establish a 12c connection on only 1 port on the pi5.
I have verified that the config,txt i2c related command lines are identical on both of the rpi's
it appears to me that the second i2c bus is partially setup on the pi5, but I cannot gain access to the second port in any way
I am new to python with very limited experience with Raspberry pi. No idea about overlays and /or kernel coding,
I may be completely off the mark, but it seems to me I may require be to update a bit of code in config.txt. to allow the pi5 to use a second i2c bus

This is the code in both pi's config.txt files that I believe is related to the i2c setup configuration.

Code:

dtparam=i2c_arm=ondtparam=i2c_vc=ondtoverlay=i2c-gpio,bus=3,i2c_gpio_sda=17,i2c_gpio_sci=27
.

when I run a i2cdetect -l command on the pi 2 b I get this result
den@raspberrypi:~ $ sudo i2cdetect -l
i2c-0i2c i2c-11-mux (chan_id 0) I2C adapter
i2c-1i2c bcm2835 (i2c@7e804000) I2C adapter
i2c-2i2c bcm2835 (i2c@7e805000) I2C adapter
i2c-3i2c 3.i2c I2C adapter
i2c-10i2c i2c-11-mux (chan_id 1) I2C adapter
i2c-11i2c bcm2835 (i2c@7e205000) I2C adapter

when I run a i2cdetect -l command on the pi 5 I get this result
globe@raspberrypi:/boot/firmware $ sudo i2cdetect -l
i2c-0i2c Synopsys DesignWare I2C adapter I2C adapter
i2c-1i2c Synopsys DesignWare I2C adapter I2C adapter
i2c-3i2c 300000002.i2c I2C adapter
i2c-13i2c 107d508200.i2c I2C adapter
i2c-14i2c 107d508280.i2c I2C adapter

I do not understand most of that but it does appear that the model 5 is show a i2c-3 port. as is the pi 2

when I run a i2cdetect -y 1 on either system i get the same valid response indicating communication on address
globe@raspberrypi:/boot/firmware $ sudo i2cdetect -y 1

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

however, when I run the same command targeting port 3 the pi 5 does not work as expected.
the pi 2 b will return the same output as above very quickly
the pi5 slowly increments through the list of i2c addresses taking about 2 minutes to complete an empty list
there is no indication of any communication at any address.

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

one more attempt i tried was to run an overlay directly in the pi5 command conseil
this is the command and the results of that attempt

Code:

globe@raspberrypi:/boot/firmware $ sudo dtoverlay i2c-gpio bus=3 i2c_gpio_sda=22 i2c_gpio_scl=23* Failed to apply overlay '0_i2c-gpio' (kernel)
I am completely lost here. I have searched using every criteria that I can think of.

I would greatly apricate any help or suggestions

How do I set up the second i2c port / buss on the raspberry pi 5

thanks in advance

Statistics: Posted by sask55 — Tue Feb 11, 2025 1:53 am



Viewing all articles
Browse latest Browse all 3838

Trending Articles