Using an I2C splitter with Pi4J

36 views
Skip to first unread message

Anders Wallén

unread,
Mar 13, 2018, 10:56:53 AM3/13/18
to Pi4J
Greetings!


I'm about to start a project where a Raspberry Pi interfaces to a number of LEDs and switches through I2C I/O cards. 

Due to the number of I/Os, multiple cards have to be used, and since they are hard-coded to use the same I2C address, a splitter card will be used to divide the bus.

The splitter card is a land-boards.com I2C-RPT, and the I/O cards are DIGIO128 from the same manufacturer. The splitter card uses the PCA9544 chip.


I have seen some Python code for usage of the splitter card, but no Java code. From the look of the Python code, extra information has to be supplied over the I2C bus to tell the splitter which card to talk to, but I have no idea of how to do that in Java; this is my first I2C project.

Does anyone have access to sample code for communicating with a PCA9544-based I2C splitter card?


Best regards,

Anders

Thomas Aarts

unread,
Mar 14, 2018, 1:43:17 PM3/14/18
to Pi4J
Until I have time to wire up one of these and supply code that I KNOW works.
Pull down a PCA9544A pdf.   I will copy the details that pertain to your question.  Nut shell.  The 9544 is on bus 1. You start, write, stop, to it's address. The data byte you write sets the control register enabling one of the attached bus.  Subsequent starts R/W stops for any address other than the 9544 are sent to the enabled bus.

Also, when you installed the pi4j code you had sample code available.  See I2CExample.java as an explanation of i2c access.

From the chip spec.
Following the successful acknowledgement of the slave address, the bus master sends a
byte to the PCA9544A which is stored in the Control register. If the PCA9544A receives
multiple bytes, it saves the last byte received. This register can be written and read via the
I 2 C-bus.

7      6         5        4      3      2        1        0 
(read/write)                           channel selection bits

INT3 INT2 INT1 INT0   X      B2     B1    B0



INT3 INT2 INT1 INT0    D3    B2    B1    B0      Command
X        X     X       X        X       0      X      X        no channel selected
X        X     X       X        X       1      0      0         channel 0 enabled
X        X     X       X        X       1      0      1          channel 1 enabled
X        X     X       X        X       1      1      0          channel 2 enabled
X        X     X       X        X       1      1      1          channel 3 enabled
0        0      0        0        0       0      0      0          no channel selected;  POR
Reply all
Reply to author
Forward
0 new messages