loading

Step 6: Designing of the I2C Relay Board

PCB Design software limitation

I am using the free version of Eagle for all my PCB designs. The software has only one limitation, and that is that the board size is restricted to 100mm x 80mm. For all my recent projects, this was acceptable.

Designing a single relay board with 16 relays and their screw terminals, was not possible on a 100mm x 80mm PCB. But it was possible to fit 8 relays with their terminal screws, a MCP23017 and ULN2803 on a single board. Instead of a single PCB, the design was changed to two identical PCBs. The only disadvantage with this option, was that instead of using all 16 I/O pins from a single MCP23017, each board had to be fitted with it's own MCP23017, and using only 8 of the 16 I/O ports.

Component selection

The design must be build using only standard through-hole components.

Connecting multiple I2C Relay Boards

The MCP23017 has three address lines (A0, A1 and A2), and each I2C Relay Board must have a unique I2C address. For easy addressing, header pins were added to set the address of each I2C Relay Board. With this option, up to 8 I2C Relay Boards can be connected to a project, to control a total of 64 relays.

Supplying power to the relays

With up to 64 relays that can be connected to a project, it is clear the power supply needed for the relays can no longer be taken directly from the main project PCB. Therefore, supply to each individual I2C Relay Board is done via screw terminals. To make it easy to loop the supply between I2C Relay Boards, two sets of screw terminals were

added.

Relay operating voltage

As there is a large selection of relays available, the design had to cater for different relay operating voltages. By using the ULN2803, the relay voltage can be between 5V and 48V DC. This makes selecting relays easier.

Connecting a load to the relays

A set of 3 screw terminals per relay allows easy connections the relay contacts (Common, Normally Open, Normally Closed). There is no common connections between the 8 relays, allowing maximum connection flexibility using the I2C Relay Board.

Connecting the I2C Bus

Connection of the four I2C Bus wires is done using headers. Again, two rows of headers were added for easy connection of multiple I2C Relay Boards.

<p>how do you use th i2c as i am new to it</p>
<p>See https://learn.sparkfun.com/tutorials/i2c for some information about the protocol.</p>
<p>Awsome instructable. where do you get the components so cheap?</p>
<p>I think most of the components were purchased from a local dealer.<br>www.rabtron.co.za</p>
<p>Guy! Very good your project. I will test and deploy. Congratulations.</p>
<p>Thank you.</p>
If I had an AC signal(say a 1000hz audio signal) that i wanted to use to switch on a relay, is there a relay that can do that?
If i want 16 relay output, I only need add another ULN2803 and the relay's circuit? I need reflash the MCP?<br>Help please... im new on this.
<p>The MCP23107 has 16 outputs, but on my PCB, I only had space for 8 relays. My PCB design makes use of GPA0..7 ports. If you want to add the other 8 relays, you can used the GPB0..7 ports as well, and just add a second ULN2803 and relays.</p><p>No programming is required on the MCP23107.</p>
<p>I was getting ready to follow up my MCP23017 LCD interface with a relay board when I came across this. Awesome job! Will be blogging about it. Take a look at my MCP23107 LCD interface at http://arduinotronics.blogspot.com/2015/11/diy-i2c-lcd.html</p>
<p>A nice little 'ible, this - and one with a lot of possibilities.<br><br>The addition of a 9-way SIL header to link from the GPB pins of the MCP23017 to the GPA pins of a second board where the MCP23017 hasn't been installed (plus the supply ground) would allow the full 16 relays to be handled by a single MCP23017.</p>
<p>Thank you.</p><p>Header pins was an option, but I could not get long enough headers locally for the second board to clear the relays on the first board.</p>
I was thinking more along the lines of sockets on the boards. Yes, extra wiring is ugly and prone to failure at the connectors, but cheap and simple.<br><br>The alternative would be DIL headers and IDC interconnect, allowing everything (including I2C and logic power) to be daisy-chained at the 'back' edge - and perhaps allowing status LEDs to be mounted on the front edge?
<p>Excellent instructable and a good illustration of engineering practice, especially as a design moves from idea to test setup to final implementation, and the decision making process at each juncture. I was inspired .</p>
<p>Thanks for the nice feedback. Glad you enjoyed it.</p>
<p>Very nice write up. Thank you.</p>
<p>Thank you</p>
<p>Awesome!</p>
<p>Thank you</p>
<p>Really epic 'ible. Great to see some other South African's here :D</p>
<p>Thank you</p>
<p>I'm an Audio video tech and we use relays a lot in A/V system to do several switching duties. This was before company like Crestron, AMX and the other popular companies that have switching thru wireless and macro sources. I found that putting a diode across the coil took care of the problem. This was also for same voltages. This circuit is great. One circuit for a multiple voltages. Great job!! </p>
<p>Thanks for the feedback. I did not install separate fly-back diodes across the relay coils, as these diodes are already part of the ULN2803 transistor array.</p>
<p>Eric, yes this is true. The relays that I used were more for higher voltages relay banks. Primarily 70v-120v and were used to prevent relay chatter that would sometimes occurred when the relay would be activated under load. I would rather use relays then any solid state. Although solid state takes up less room there are some places good old fashion Electronics can not be replaced. It's great to see so many fellow techs and engineers coming together to talk shop with open minds and excitement to share. And Erick thank you for interacting and creating a discussion not a debate. Peace ModSceintist</p>
<p>If one want to go into a debate, there will be endless options for each and every design. One needs to look at the inputs of a design, decide what to do with the data, and control outputs with this data.<br>With the technology available, there will be endless options to choose from. But I am limited to a very small local electronic supplier, and must use what they have available. </p><p>For 12 - 220V loads, I have always preferred the good old trusty relay. Just because it provides electrical isolation.</p><p>Thanks again for your nice feedback. </p>
<p>Great 'ible! Thank you for your time and attention to detail in putting this into an easy to understandable format. I understood most of it on the first read ;)</p>
<p>Thank you for the nice feedback.</p>
<p>hi friend,</p><p>since you made this wonderful instructable you can add the information regarding the very well-known processor AT328 or the AT168.<br>if you have one of those or other in the same series or even another proccessor that uses a serial output, you can easily expand the outputs by using a shifter - 74HC595<br><br>greets!</p>
<p>+ awesome improvement for the relays array:</p><p>you can use a &quot;moc&quot; component (for example the moc3021).<br>it has the same use as the relay has, though you need to make a slight change for your scheme.<br><br>here are the advantages:</p><p>1. moc's current is much lower comparing to relay's.</p><p>2. no mechanic parts inside - meaning you can switch on and off with a high speed &amp; accuracy and without physical deterioration.</p>
<p>I agree. It all depends on what you want to switch. The moc devices are much more expensive compared tothe relays when one wants to switch 5A loads.</p>
<p>See Step 9 for an example and source code to use the board with an Arduino. </p><p>As I wanted to keep the number of wires between the boards to a minimum, I opted for the I2C method (4 wires) instead of the 74HC595 (5 wires).</p>
<p>Nice project.</p><p>A word of caution, however: The board, as designed, is not &quot;legally&quot; safe to use to switch mains voltages. The reason is that you have coil traces too close to contact traces. The legal minimum, mandated by safety authorities, is 6.4mm in the US and 8mm in Europe. Your layout has roughly one quarter that spacing. This spacing is called creapage distance.</p><p>The problem is that dirt on the PCB can result in an arc-over and possible electric shock, or worse.</p><p>If anyone intends to use this board on 120/240V, it can be made &quot;informally&quot; safe by giving it a good clean with alcohol and then, when it's dry, coating the board. Almost any lacquer will do, though ideally proper conformal coating. I say &quot;informally&quot; because this measure is allowed in some jurisdictions, but only if the coating process is carried out in a quality audited facility.</p><p>The other thing that could be done is to mill slots in the PCB between the mains and low voltage parts of the circuit. Further information: http://forum.arduino.cc/index.php?topic=137049.0</p>
<p>Thanks for your good feedback. Although I did not mention it, I do clean all my boards with flux remover, then water, and afterwards cover all my PC boards with lacquer after testing.</p><p>But on the next batch of boards, I will keep this in mind, and use jumpers to connect the common supply rails to the relays.</p>
Eric, nIce to hear you clean and coat your boards. <br><br>If you have the choices in SA, and intend to revise the PCB, you might hunt around for relays that have the coil pins well separated from the contacts. For example Hong Fa JQX14FW or FF. I am not sure how the footprint would work for you. I am &quot;retired and divested&quot; now but &quot;we&quot; use(d) thousands of those.<br><br>BTW, Having to do it all myself, now, I designed my first PCB in 20 years last week. I shied away from Eagle because of the size limitation, and went with DesignSpark PCB (a whole new learning curve!). It has some rough edges, but it did the job, including auto-routing a passable first approximation.
<p>Thanks for all your feedback. The relays I use, are the only once cheap enough for hobby used. When I revise the PCB, I will give DesignSpark a test. </p>
<p>A very well done instructable, very nice work!</p>
<p>Thank you</p>
<p>Thank you.</p>
<p>+1 for use of the MCP23017, well done!</p>
<p>Thanks</p>
<p>Just as an idea for future improvements, if you can drag the extra 8 i/o pins from the MCP23017 so you could stack a daughter board with a second uln2803 and relays, you could be controlling all 128 relays that it would be possible if you could build larger boards. Another option would be to use smaller relays if what you are switching on and off can work with them. You might look at relays like the NTE R56S&minus;5D.5&minus;24D and use a 3pin header for co/no/nc connections instead of screw terminals. But yes, that would reduce the load you could control per relay.</p>
<p>I agree, and I did have a look at the daughter board option. Then I got lazy....</p>
<p>Great Instructable. I will save this for a future project. You can get the MCP23017 and ULN2803 as free samples from the manufacturers' web sites. </p><p><a href="http://www.microchip.com/wwwproducts/Devices.aspx?product=MCP23017#pricindAndSamples" rel="nofollow">http://www.microchip.com/wwwproducts/Devices.aspx?...</a><br><a href="http://www.ti.com/product/ULN2803A/samplebuy" rel="nofollow">http://www.ti.com/product/ULN2803A/samplebuy</a></p>
<p>With the non-existing postal service in South Africa, the average waiting time for a parcel abroad can be up to 12 months.</p><p>Lucaly, these chips are available locally.</p>
<p>another great improvement you can easilly made : use the non used pins of MCP23017 or 23018 as inputs ;)</p>
<p>I agree. But for the original design, I needed all the relays, and due to PCB size limitations in Eagle, I did not have space for more functions.</p>
<p>Loved step 10, I appreciate your generosity.</p>
<p>You are welcome</p>
<p>nice informative tutorial, nice work.</p>
<p>Thank you</p>

About This Instructable

71,104views

689favorites

More by Eric Brouwer:7 Segment Up/Down Counter Designing a Dual 40A PWM Speed Controller for Brushed Motors Automated Power Tool Charger 
Add instructable to: