tilllt
Posts: 3
Joined: Thu Jun 18, 2020 4:07 pm

[Solved] I2C Bus 5 on PIO Pin 10&11 / ADS1115 Problem

Fri Jun 19, 2020 10:01 am

Hi,

i am a bit a loss here, trying to use GPIO pins 10&11 as i2c5. i cannot use the default i2c bus because i am using a custom made HAT which occupies pretty much all other available i2c pins with other GPIO functionality and cannot be rewired.

So, GPIO10/11 is the Candidate i want to get to work
raspi-gpio funcs

GPIO, DEFAULT PULL, ALT0, ALT1, ALT2, ALT3, ALT4, ALT5
[...]
10, DOWN, SPI0_MOSI, SD2, DPI_D6, I2CSL_SDA_MOSI, CTS4, SDA5
11, DOWN, SPI0_SCLK, SD3, DPI_D7, I2CSL_SCL_SCLK, RTS4, SCL5
[...]

The device i am trying to connect, is an ADS1115 Adafruit Breakout Board Clone.
Obviously i enabled i2c in config.txt
dtparam=i2c_arm=on

then i switch GPIO pin 10&11 to ALT5 functionality, as listed in the output of raspi-gpio funcs:
gpio=10-11=a5

then i configure pin 10&11 to be used as i2c bus5
dtoverlay=i2c5,pins_10_11

Device is there:
ls /dev/i2c*
/dev/i2c-1 /dev/i2c-5

but the connected i2c device doesnt show.

Code: Select all

pi@coronaroller:~ $ sudo i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
pi@coronaroller:~ $ sudo i2cdetect -y 5
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
anything i am missing or is the ads1115 maybe not working?
anything else i can do to debug?
Last edited by tilllt on Mon Aug 17, 2020 11:54 am, edited 1 time in total.

tilllt
Posts: 3
Joined: Thu Jun 18, 2020 4:07 pm

Re: I2C Bus 5 on PIO Pin 10&11 / ADS1115 Problem

Tue Aug 11, 2020 8:34 pm

Nobody answered but i found the solution the meanwhile.
There are lots and lots of non working solutions to get the RPi 4's additional i2c ports working, but this (afaik) is the only working, in my example to get I2C5 working on alternative GPIO Pins 10&11

Add to config.txt

Code: Select all

dtparam=i2c=on
gpio=10-11=a5,pu (if you want pullup enabled, else omit the pu)
dtoverlay=i2c5,pins_10_11
... and there is the ads1115:

Code: Select all

sudo i2cdetect -y 5
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- 48 -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
The most notable misleading way is this, which DOES NOT WORK imho since it leaves the original pins enabled simultaneously.

Code: Select all

dtoverlay=i2c5,sda5_pin=10,scl5_pin=11,pin_func=5
hope it helps someone,
cheers.

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 9245
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: I2C Bus 5 on PIO Pin 10&11 / ADS1115 Problem

Wed Aug 12, 2020 9:54 am

https://github.com/raspberrypi/linux/bl ... ADME#L1397 (also accessible via "dtoverlay -h i2c5")

Code: Select all

Name:   i2c5
Info:   Enable the i2c5 bus
Load:   dtoverlay=i2c5,<param>
Params: pins_10_11              Use GPIOs 10 and 11
        pins_12_13              Use GPIOs 12 and 13 (default)
        baudrate                Set the baudrate for the interface (default
                                "100000")
So adding parameters sda5_pin, scl5_pin, and pin_func will do nothing.

I2C requires a pullup on each of the two lines. The internal pullups in the SoC are around 50kohm. I2C generally wants 1.5-2kohm, hence the two resistors 1k8 R23 & R24 shown in the 3B+ schematics and most of the others variants, as GPIOs 2&3 are the normal GPIOs for i2c-1. Too high a value on the pullup will result in erratic response if the line capacitance gets too high (the line becomes slow to return to the high state).

You shouldn't need to set gpios 10 & 11 to a5 via a gpio= line in config.txt - the dtoverlay should do it automatically for you. It's probably the pull up that you need.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

tilllt
Posts: 3
Joined: Thu Jun 18, 2020 4:07 pm

[Solved] Re: I2C Bus 5 on PIO Pin 10&11 / ADS1115 Problem

Mon Aug 17, 2020 11:50 am

Ok,

that was the last thing that kept the ADS1115 from working. Like 6by9 mentioned, the internal pull-up resistor made the ads1115 detectable but still the python code bailed with a "communication error".

Adding a 1.8k pullup resistor to SDA5/SCL5 - like in the linked schematic and setting GPIO10/11 to NP (no pull) - made things work

So, big thanks to 6by9 for pointing this out.

Return to “Interfacing (DSI, CSI, I2C, etc.)”