The Raspberry Pi has the ability to read a maximum of 26 input signals through its GPIO pin header. Now consider a scenario when you want to read more than 26 signals. That will mean that you have to implement some sort of multiplexing or use extra hardware to do this. Thankfully Sequent Microsystems have the right solution for this.
Their Stackable cards give you the ability to read up to 16 inputs using just 2 pins of the i2c port, leaving you with all the rest of the 24 pins. These are optically isolated inputs capable of reading both DC and AC signals with a voltage range pf 3 to 24 volts. A step by step process for configuring both your Stackable cards (The 16 Universal Inputs 8-Layer Stackable Card and the Home Automation 8-Layer Stackable Card) and raspberry pi has been presented here below.
Enable i2c protocol
pi@raspberrypi:~ $ sudo raspi-config
Check if Ic2 is enabled
pi@raspberrypi:~ $ lsmod | grep i2c_
i2c_bcm2835 16384 0
i2c_dev 20480 0
Testing Hardware
sudo i2cdetect -l
i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- 23 -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
Set up ic2 to work in python
sudo apt-get install -y python-smbus
sudo apt-get install -y i2c-tools
Configure 16 Universal Inputs 8-Layer Stackable Card for Raspberry Pi

pi@raspberrypi:~ $ git clone https://github.com/SequentMicrosystems/16inputs-rpi.git
Cloning into '16inputs-rpi'...
remote: Enumerating objects: 87, done.
remote: Counting objects: 100% (87/87), done.
remote: Compressing objects: 100% (76/76), done.
remote: Total 87 (delta 36), reused 9 (delta 5), pack-reused 0
Unpacking objects: 100% (87/87), done.
pi@raspberrypi:~ $ cd /home/pi/16inputs-rpi
pi@raspberrypi:~/16inputs-rpi $ sudo make install
[Compile] src/16in.c
[Compile] src/comm.c
[Link]
[Install]
pi@raspberrypi:~/16inputs-rpi $ 16inputs -h
-v Display the 16inputs command version number
-h Display the list of command options or one command option details
-warranty Display the warranty
-list: List all 16inputs boards connected
return the # of boards and stack level for every board
rd: Read inputs state
Installing and using the lib16in python library for the 16 Universal Inputs 8-Layer Stackable Card for Raspberry Pi
pi@raspberrypi:~/16inputs-rpi $ sudo apt-get update
pi@raspberrypi:~/16inputs-rpi $ sudo apt-get install build-essential python-pip python-dev python-smbus git
pi@raspberrypi:~/16inputs-rpi $ cd python/16inputs/
pi@raspberrypi:~/16inputs-rpi/python/16inputs $ sudo python3 setup.py install
Usage
import lib16in
print(lib16in.readCh(0,7))
Configure the Home Automation 8-Layer Stackable Card for Raspberry Pi

pi@raspberrypi:~ $ git clone https://github.com/SequentMicrosystems/ioplus-rpi.git
Cloning into 'ioplus-rpi'...
remote: Enumerating objects: 343, done.
remote: Counting objects: 100% (95/95), done.
remote: Compressing objects: 100% (89/89), done.
remote: Total 343 (delta 33), reused 18 (delta 4), pack-reused 248
Receiving objects: 100% (343/343), 812.86 KiB | 850.00 KiB/s, done.
Resolving deltas: 100% (146/146), done.
pi@raspberrypi:~ $ cd /home/pi/ioplus-rpi
pi@raspberrypi:~/ioplus-rpi $ sudo make install
[Compile] src/ioplus.c
[Compile] src/comm.c
[Compile] src/thread.c
[Compile] src/gpio.c
[Compile] src/opto.c
[Link]
[Install]
pi@raspberrypi:~/ioplus-rpi $ ioplus
Usage: ioplus -v
Usage: ioplus -h Display command options list
Usage: ioplus -h <param> Display help for <param> command option
Usage: ioplus -warranty
Usage: ioplus -pinout
Usage: ioplus -list
Usage: ioplus <stack> board
Usage: ioplus <id> relwr <channel> <on/off>
Usage: ioplus <id> relwr <value>
Usage: ioplus <id> relrd <channel>
Usage: ioplus <id> relrd
Usage: ioplus <id> reltest
Usage: ioplus <id> gpiowr <channel> <on/off>
Usage: ioplus <id> gpiowr <value>
Usage: ioplus <id> gpiord <channel>
Usage: ioplus <id> gpiord
Usage: ioplus <id> gpiodirwr <channel> <out/in>
Usage: ioplus <id> gpiodirwr <value>
Usage: ioplus <id> gpiodirrd <pin>
Usage: ioplus <id> gpiodirrd
Usage: ioplus <id> gpioedgewr <channel> <edges>
Usage: ioplus <id> gpioedgerd <pin>
Usage: ioplus <id> gpiocntrd <channel>
Usage: ioplus <id> gpiocntrst <channel>
Usage: ioplus <id> optrd <channel>
Usage: ioplus <id> optrd
Usage: ioplus <id> optedgerd <pin>
Usage: ioplus <id> optedgewr <channel> <edges>
Usage: ioplus <id> optcntrd <channel>
Usage: ioplus <id> optcntrst <channel>
Usage: ioplus <id> optencwr <channel> <0/1>
Usage: ioplus <id> optencrd <pin>
Usage: ioplus <id> optcntencrd <channel>
Usage: ioplus <id> optcntencrst <channel>
Usage: ioplus <id> odrd <channel>
Usage: ioplus <id> odwr <channel> <value>
Usage: ioplus <id> dacrd <channel>
Usage: ioplus <id> dacwr <channel> <value>
Usage: ioplus <id> adcrd <channel>
Usage: ioplus <id> adccal <channel> <value>
Usage: ioplus <id> adccalrst <channel>
Usage: ioplus <id> daccal <channel> <value>
Usage: ioplus <id> daccalrst <channel>
Usage: ioplus <id> wdtr
Usage: ioplus <id> wdtpwr <val>
Usage: ioplus <id> wdtprd
Usage: ioplus <id> wdtipwr <val>
Usage: ioplus <id> wdtiprd
Usage: ioplus <id> wdtopwr <val>
Usage: ioplus <id> wdtoprd
Usage: ioplus <id> iotst
Where: <id> = Board level id = 0..7
Type ioplus -h <command> for more help
Installing and using the libioplus python library for the Home Automation 8-Layer Stackable Card for Raspberry Pi
pi@raspberrypi:~/16inputs-rpi $ sudo apt-get update
pi@raspberrypi:~/16inputs-rpi $ sudo apt-get install build-essential python-pip python-dev python-smbus git
pi@raspberrypi:~/16inputs-rpi $ cd python/ioplus/
pi@raspberrypi:~/16inputs-rpi/python/16inputs $ sudo python3 setup.py install
Usage
import library and read voltage level at board stack number 6, channel 1
import libioplus
print(libioplus.getAdcV(6, 1))