1

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.

-Thanks

[EDIT]: 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.

[EDIT 2]: 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?

6
  • 1
    Two quick thoughts - are you mixing up BCM and PIN numbers (can’t download pics at the mo?!?) and are you sure the relay is i2c? Could you put a link to it in your main post (just edit it) rather than a comment please.
    – user115418
    Apr 8 '20 at 22:56
  • 1
    Have you tried reading the documentation in /boot/overlays/README?
    – Milliways
    Apr 9 '20 at 0:42
  • @Shaun the Sheep, (1) The I2C drivers for Rpi3B+ stretch are not official and NOT OS version invariant. Rpi4B buster "official" doc says you can have 5 I2C buses, but I found that system is not stable/reliable when you set up 3 or more I2C buses. (2) You might be interested to read my not very successful Rpi4B buster multiple I2C bus experiments: penzu.com/public/f0416d22. Good luck and cheers.
    – tlfong01
    Apr 9 '20 at 7:15
  • @Andyroo, I've added a link to the relays, and I was under the impression that when writing in the config.txt, I would be using the bcm numbers to reference the pins that I want to operate on. Apr 9 '20 at 11:56
  • @Milliways I have read the README in '/boot/overlays', that is actually where I got the infromation that 'i2c_gpio_delay_us' "effects baud rate", is what I said. Though looking at it again, it says that it effects the clock delay. Apr 9 '20 at 11:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.