Bread Crumb Link
Home Free_Shipping Contact_Us Designed_By
Shop Pages
Shop Newsletter

Add my Store to your
Favourites and receive my email newsletters about new items and
special promotions!

General Interest

IO Extender Plus+ Quick Start Guide
IO Extender Plus+ Getting Started

The Smart Elex IO Extender PLUS+ is a Raspberry Pi breakout Adaptor with an extra 16 IO ports

The IO Extender Plus+ uses the MCP23017 IO Expander Chip to give you the extra 16 IO ports.

IO Extender PLUS+ Features
  • Breaks out the Raspberry Pi 26way e.g.+3.3v, i2c, GPIOs etc.
  • 16bit Remote bidirectional IO ports with high speed I2C Interface
  • Breadboard power supply with jumper switch +3.3v or +5v.
  • Blue LED power indicators
  • Three MCP23017 Hardware address pins


IO Extender PLUS+ Pin Outs

Pin numbering 1



Setting up the Raspberry Pi for I2C with the IO Extender Plus+

The IO Extender Plus+ needs additional software installed before we can use it. In particular, we must configure the I2C bus. I2C drivers are disabled by default. Let’s enable them. We’ll need to edit a couple system files, install a couple software packages, and then reboot.

From the command line, enter:
sudo nano /etc/modprobe.d/raspi-blacklist.conf'

Look for an entry like 'blacklist i2c-bcm2708'. Add a hash mark '#' at the beginning of that line:

Press CTRL X then y to save and exit.

Next edit the modules file by:
sudo nano  /etc/modules

Add i2c-dev on a new line, then save and exit.

Next, install some tools and python support run the following 3 commands:
sudo apt-get update
sudo apt-get install python-smbus
sudo apt-get install i2c-tools

Now add a new user to the i2c group:
sudo adduser  pi i2c

Shut down your pi now:
sudo halt

Turn off the power and plug your IO Extender Plus+ into your Raspberry Pi and breadboard.
turn on the power, and log back in to the pi account.
From the command line, enter:

For Rev 1 Raspberry Pi
sudo  i2cdetect -y 0

For Rev 2 Raspberry Pi
sudo  i2cdetect -y 1

You should see the following output with your MCP23017 chip on port 0x20
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: 20 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

This indicates that your pi is communicating with the MCP23017 on the IO Extender Plus+ (Default address 0x20).


Addressing The IO Extender Plus+

The MCP23017 is addressable enabling you to have upto 8 different I2C devices on the I2C data bus.

So you could have 8 IO Extender Plus+ devices giving you 128 IO ports. the default setting for the IO Extender Plus+ is all three jumpers ON 0x20.

Below is the jumper address pin configurations 0-7

GPIO Header

Task 1
Connecting 8 LEDs to the GPA Ports and make them Flash.

Light-emitting diode (LED)

Current flows from the anode to cathode.

  • Anode: longer pin
  • Cathode: shorter pin

Use a multimeter to test the polarity

  • Check resistance
  • In both directions.


Pin numbering 1

Simple LED Circuits

Pin numbering 1

In this task we will wire up 8 leds to each GPA port on the IO Extender Plus+.

we will be using the circuit B from above 8 x.

Small Steps

Now that I2C is working and we have the leds connected its time to talk to the LEDs! The i2cset utility in the i2c – tools package lets us send data. The format is “i2cset -y <bus number> <chip addr> <data addr><value>”. Option -y is not required, but turns off alot of scary - sounding warnings.

We will send data to the IO one byte at a time.

The bus number is 0 for Rev 1 Raspberry Pi’s and 1 for Rev 2 Raspberry Pi's. Try these, in the order shown, omitting the comments:

i2cset -y 1 0x20 0x00 0x00 #set port A to all outputs
i2cset -y 1 0x20 0x01 0x00 #set port B to all outputs
i2cset -y 1 0x20 0x13 0x00 #set all port B (row) pins low
ic2set -y 1 0x20 0x12 0xFF #set all port A (column) pins high; LED  turns on!
ic2set -y 1 0x20 0x12 0x00 #enter this to turn the LED off

Below is a python example to turn all leds on and off repeating until user exits the script.

Try using idle or a text editor and write the below script once complete run the script and see what the results are.

#Import smbus
import smbus

#Import time for timing delays
import time

#Set definitions for the MCP23017 Chip (ADDRESSING)

ADDR0 = 0x20 #I2C Bus Address of the MCP23017
BANKA = 0x00 #Port A IO Direction Register
BANKB = 0x01 #Port B IO Direction Register
PORTA = 0x12 #Port A Data Register
PORTB = 0x13 #Port B Data Register

# Start of program #

#Set Variable To Write To And From The BUS

#Raspberry Pi REV1 = 0
#Raspberry Pi REV2 = 1
#bus = smbus.SMBus(0)#REV1
bus = smbus.SMBus(1) #REV2
#Set all IOs to Outputs
#All Zeros = All Port A Outputs
#All Zeros = All Port B Outputs
#Set All PortA To HIGH (Cathodes To +3.3v)
#Set All PortB To HIGH (Cathodes To +3.3v)
print "HELLO Welcome To Smart-Elex I2C Tutorial 1" pause = raw_input("How long do you want the LED to Pause? (In milliSeconds) ")
print ""
print "Running...."
print ""
print "Press Ctrl + C to Stop Program"
print "Then Press Ctrl + D to Close The Window"

while (1):
#Loop Until User Halts the Program
#Set Ports HIGH/LOW

#Set PortA Outputs to Low = Turn LEDs On
#Keep LED On For User Defined in MilliSeconds
time.sleep(int(pause)/ 1000.0)
#Set PortA Outputs to high = Turn LEDs Off
#Keep LED On For User Defined in MilliSeconds
time.sleep(int(pause)/ 1000.0)

Now try changing the code to turn only one or two leds on.

This is easy all we do is change the hex values in the following two lines

#Set PortA Outputs to Low = Turn LEDs On

How to work out required hex value.

Below is a table showing the binary value to switch GPA2 and GPA4.

Pin numbering 1

Visit this useful website Enter the above binary code and the calculator will give you the require hex value. e.g. D7

So the required hex value for the while loop is 0xD7

Your code should look like the below two lines.

#Set PortA Outputs to Low = Turn LEDs On

Try changing the python code and see the results.

Visit our forum for more tutorials