The PCA9536 is an 8-pin CMOS device that provides 4 bits of General Purpose parallel Input/Output (GPIO) expansion for I2C-bus/SMBus applications. It consists of a 4-bit Configuration register to serve the purpose of input or output selection, 4-bit Input Port register, 4-bit Output Port register and a 4-bit Polarity Inversion register active HIGH or active LOW operation. Here is its demonstration with the raspberry pi using java code.
Step 1: What You Need..!!
1. Raspberry Pi
LINK : https://www.controleverything.com/content/Digital-IO?sku=PCA9536_I2CIO
3. I²C Cable
LINK : https://www.controleverything.com/content/I2C-Cables?sku=I2CAFF3
4. I²C Shield for Raspberry Pi
LINK : https://www.controleverything.com/content/I2C-Master?sku=TOUTPI2
5. Ethernet Cable
Step 2: Connections:
Take an I2C shield for raspberry pi and gently push it over the gpio pins of raspberry pi.
Then connect the one end of I2C cable to PCA9536 sensor and the other end to the I2C shield.
Also connect the Ethernet cable to the pi or you can use a WiFi module.
Connections are shown in the picture above.
Step 3: Code:
The java code for PCA9536 can be downloaded from our github repository- ControlEverythingCommunity
Here is the link for the same :
The datasheet of PCA9536 can be found here:
We have used pi4j library for java code, the steps to install pi4j on raspberry pi is described here:
You can also copy the code from here, it is given as follows:
// Distributed with a free-will license.
// Use it any way you want, profit or free, provided it fits in the licenses of its associated works.
// This code is designed to work with the PCA9536_I2CIO I2C Mini Module available from ControlEverything.com.
public class PCA9536
public static void main(String args) throws Exception
// Create I2C bus
I2CBus Bus = I2CFactory.getInstance(I2CBus.BUS_1);
// Get I2C device, PCA9536 I2C address is 0x41(65)
I2CDevice device = Bus.getDevice(0x41);
// Select configuration register
// All pins configured as inputs
// Output to screen
System.out.printf("All Pins State are HIGH %n");
// Read 1 byte of data
byte data = new byte;
data = (byte)device.read(0x00);
// Convert the data to 4-bits
int data1 = (data & 0x0F);
for(int i=0; i<4; i++)
if((data1 & ((int)Math.pow(2, i))) == 0)
System.out.printf("I/O Pin %d State is LOW %n", i);
System.out.printf("I/O Pin %d State is HIGH %n", i);
Step 4: Applications:
PCA9536 can be employed as an I/O expander. It provides a simple solution when additional input/output is required. Usually it is employed in systems which require expansion for ACPI power switches, sensors, push buttons, LEDs, fans, etc.