I decided to add additional i2c buses to my raspberry pi 4 through the use of gpios and overlays. I first came across this idea from this post by the instructables. Through editing the config.txt file found in /boot, you can add i2c buses,set the pins and interact with devices as if they were connected to the originally specified i2c pins on the pi. The only thing I needed to keep in mind was to have pull up resistors for each gpio. In addition to the post by the instructables, I found another post where another person followed the instructables post, and after some difficulty was able to get their i2c buses setup. Since I was doing essentially the same thing, I used their post for guidance.
The problem we both ended up running into was that our devices were unable to be detected when trying to
i2cdetect the bus that the device is supposed to be connected to. I read up on solutions to the post, and that led me to a third post which had me creating, compiling and copying a file in the device tree to /boot.
Currently, the lines I've edited in my config.txt file looks like this:
44 45 # Uncomment some or all of these to enable the optional hardware interfaces 46 dtparam=i2c_arm=on 47 #dtparam=i2s=on 48 dtparam=spi=off 49 dtoverlay=i2c-gpio,bus=8,i2c_gpio_delay_us=2,i2c_gpio_sda=23,i2c_gpio_scl=24 50 dtoverlay=i2c-gpio,bus=7,i2c_gpio_delay_us=2,i2c_gpio_sda=17,i2c_gpio_scl=27 51 52 # Uncomment this to enable the lirc-rpi module
I've added the lines needed to add and detect the buses I want, but like stated, nothing is being detected on either of these buses. I've tried all sorts of little things to see if my device would be picked up (Even tried playing with
i2c_gpio_delay_us= which apparently effects the baud rate?).
My wiring is essentially identical to the picture here, from the resistors, to gpios used. The difference being I'm wired up to a relay board instead of the sensor shown. If it's really necessary, I can show my wiring.
In addition to things that confuse me, when I was adding these new i2c buses that would be controlled by the gpios, I noticed that the buses picked up were 8 & 7 by default:
:~ $ i2cdetect -l i2c-1 i2c bcm2835 I2C adapter I2C adapter i2c-8 i2c i2c@8 I2C adapter i2c-7 i2c i2c@7 I2C adapter
I'm not sure if this could be part of the problem or not. I'm really stumped here and would love some insight as to what possibly the problem is or where it's coming from. I might have missed something on the forums I went through, but I wasn't able to find how people have resolved this problem, and I'm very sure of my wiring. Not to mention, multiple people have found success doing this, so I must be missing something.
Here's a link to the relay boards that I'm using. A little note about these relays, you use
i2cset to write to the relays. Also, through experimentation, I know that the minimum amount of pins needed to operate this board are:
-5v(pin 2 or 4)
-i2c SDA & SCL (pin 3 & 5)
-3v3 (pin 1)
-ground (pin 6)
I've been able to run individual wires to these specific pins on the relay board, and was able to operate and detect as normal from the raspberry pi 4.
Something I just noticed after pin and bcm numbers was mentioned was the function series found in
/boot/overlay/README called i2cx (x being the i2c bus number). Does the specific bus I need also need to be enabled this way?