I/O Module


This module is designed to provide I/O management for the Raspberry Pi. Apart from providing more I/O cpntrol pins, it allows the Raspberry Pi to control higher power devices outside the current and voltage capabilities of the Raspberry Pi I/O pins.

2 x 16-Channel Input/Output Boards

The MCP23017 is capable of reading/writing 16-bit bits of data using the I2C interface.

An internal integrated power-on reset (POR) circuit resets to the device's default state. It has two programmable interrupt source outputs that can be used individually, or combined as one signal. The polarity toggle register configures the GPIO input polarity and can also be configured as an output. It can be set to use a pull-up resistor, and the IO configured as an input or output. The IO port has strong driving capability, and the current sinking and sourcing current can reach 25mA.

2 x Open Collector Switch Chips

The ULN2803a is an eight (8) channel darlington array. Each channel contains a Darlington transistor with suppression diodes to allow the handling of inductive loads. The collector current rating of each channel is 500mA, although channels can be paralleled for higher current capability.

One of these chips has its common free wheeling diodes connected to the +5V supply and the other is connected to the +12V supply. This connection allows inductive loads to be safely used with either the +5V or +12V powered items.

Equipment that will be connected to these switches will be:

(1) MQ135 Gas Air Quality Sensor. A high draw 5V sensor that will be switched to reduce its power drain when not required,

(2) Enclosure Fan. A 12V high current draw (0.4A) fan that will be used to turn over the air in the enclosure more rapidly to aid cooling. This fan will be turned off unless needed to reduce power draw and to extend the life of the fan.

(3) Raspberry Pi Fan. A medium draw 5V fan used to cool the Raspberry Pi. Unlike the other switch outputs, this one will be controlled directly by an I/O pin on the Raspberry Pi.

Physical Construction

The I/O Module is built on a 6cm x 4cm prototype board, with two (2) MCP23017 modules mounted vertically on the board. There are two (2) ULN2803a open collector Darlington arrays. One array has its flyback diodes connected to the +5V supply. This MUST be connected to the +5V rail as this also supplies power to the MCP23017 chips.

The other array can be connected to the +5V, +12V or +24V supplies to match the supply to inductive loads.

The open collector outputs may be paralleled to increase the load current that may be switched, as long as the software controls the corresponding input bit simultaneously. Each output can switch up to 350mA, while the total current for all channels should not exceed 2A.

Terminal Block Pinout

The electronics of this device are constructed on a 5cm x 7cm prototype board. Two (2) 18-pin and two (2) 28-pin IC (Integrated Circuit) sockets are soldered onto the board, along with a 40-pin male IDC connecter that will ultimately connect to the same type of terminal strip as the Raspberry Pi uses.

Because two (2) MCP23017 units are being used on the same bus, the address on one of the units must be changed by altering the jumper on the A0 address line. The unit where the address is not altered will have the address 20, while the one with the change to the A0 address line will be 21.
To confirm this is the case, connect the +3.3V supply and the Earth to pin 40 and 21 respectively on the I/O Module's IDC connector. NOTE Connecting the module's supply to the +5V supply will damage the Raspberry Pi in a most expensive manner.

The SCL and SDA lines from the Raspberry Pi are then connected to the module's SCL and SDA pins, and the system power up. When you log into the Raspberry Pi enter the following command and confirm that result matches the example below.

mark@ares:~ $ i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: 20 21 -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --                        

When you are wiring up the terminal strip that is connected to the I/O module, to copy this project, the +5V supply is connected to Pin 15, and the Earth of the +5V supply is connected to Pin 17. Pins 1 and 3 are connected to the Switched Earth pins of the Raspberry Pi's fans, so that they can be controlled by the Raspberry Pi. If this module is used to switch units connected to the +12V supply and the loads are likely to be inductive, the +12V supply should be connected to

Licenced under Creative Commons Attribution Share Alike 4.0 International or better by Mark Little (2022 - 2023)