Creating Multiple I2C Ports on a Raspberry PI

Daniel Ellis Research
CEMAC
Published in
3 min readDec 16, 2020

--

Sometimes we require multiple modules all of which communicate using the I2C channel. In this post, we discuss how to do exactly that using available GPIO pins.

Photo by Josh Spires on Unsplash

Setup

We begin with installing the required libraries,

sudo apt-get install -y python-smbus i2c-tools

followed by enabling I2C using the advanced tab within raspi config. I this does not make sense, have google ‘using I2C on Raspberry Pi’ and the device you are trying to connect. Make sure you can connect this successfully before continuing.

Conventional I2C ports

Generally, to set up we use pins 3 and 4 (see the diagram below) to connect a device. In my case, it is a simple ‘plug-and-play’ real-time clock (RTC). Next, we can check that the PI reads our device on the default port.

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

--

--

Daniel Ellis Research
CEMAC
Editor for

Research Software Engineer specialising in High-Performance Computing and Data Visualisation. — PhD in Atmospheric Chemistry and Masters in Theoretical Physics.