I wanted to set up a Christmas light display using LED Lights. The LED Lights would require less power, allowing the use of a single 15 amp circuit. Using a Raspberry Pi was an easy decision, given the amount of information available on the internet and the low purchase price (under $30 at Micro Center).
The initial design was to control 32 strands of lights, but with the Christmas tree taking up 16 strands and the leaping lights taking up another 16 strands, I decided to increase the total number of relays to 64.
Simply using GPIO pins would not allow me to control that many relays, so I begin to investigate my options and discovered the wiringpi website. The site provided the necessary information to move the project forward. Using i2c with a 16 input/output port expander was the first step in my solution.
You can attach multiple MCP23017s to the two i2c pin
s on the Raspberry Pi to obtain 16 general purpose pins per chip. Using four MCP23017 expansion chips, I could add 64 additional pins to the raspberry.
I found the IO Pi Plus, manufactured by AB Electronics in the UK, using an internet search. It is a 32 channel digital expansion board designed for the Raspberry Pi. A pair of MCP23017 chips are on the board allowing you to connect up to 32 digital inputs or outputs. Using two of the boards gave me the 64 pins required.
Having all the relays on at the same time raised the concern of how much power the relay circuit would require, and could the MCP23017 handle the total demand. Some additional research was required after I damaged one IO Pi Plus board in a 32 relay test.
The 16 channel relays I selected used opto-isolation and indicated that each relay would require 15-20mA Driver Current; therefore, the worst case was 320mA per board. The MCP23017 has a maximum output of 150mA.
Finding the “ULN BOB” 16 Channel Darlington Driver IC Breakout Board was the solution to this potential problem. It allowed me to have all 64 relays turn on at the same time. The Darlington can handle 500mA per output.
Another extender card that I found was the JeeLabs Output Plug, which is a small board that contains an 8-bit I/O expander plus an NPN darlington array. An I2C bus, with all the power and signal lines, are available on the other side of the board to allow daisy-chaining with other I2C conformant boards.
Putting it all together in a compact space required some creativity. The one thing that was an oversight in the final design was access to the SD card on the Raspberry Pi. I would recommend an SD extension cable to allow you to move the SD card to a location that can be accessed more easily.