Page 1 of 1
Control multiple relays with only One gpio pin (mcp23017)
Posted: Fri Oct 26, 2018 2:36 am
by cscuilla
I have four relays hooked up which I want to power on and off all at the same time. They are all powered by external power supplies separate from the Pi/mcp23017. Can I hook the signal pins all up to the same mcp23017 output pin so that when i turn that pin high all the relays turn on?
Or do i need to hook each relay up to its own output pin.
I've tested with two relays hooked up to one output and it works, but i'm wondering if it is safe or would cause damage, and if it is safe, then how many relays can i hook up to the same pin?
Re: Control multiple relays with only One gpio pin (mcp23017)
Posted: Fri Oct 26, 2018 3:30 am
by LTolledo
one "trick" you can use is to let one pin of the MCP23017 to control 1 relay (ex relay-1), and that relay-1 will control the other relays (relay-2, relay-3, .... relay-n) .
just make sure that the total current of all the relay coils passing thru relay 1 does not exceed 50% of the contact point maximum rating on relay-1
Re: Control multiple relays with only One gpio pin (mcp23017)
Posted: Fri Oct 26, 2018 8:31 am
by davidcoton
cscuilla wrote: ↑Fri Oct 26, 2018 2:36 am
i'm wondering if it is safe or would cause damage, and if it is safe, then how many relays can i hook up to the same pin?
You need to know to current draw (at 3V3) or sink (at 0V) of the relay input -- presumably there is a driver of sonme sort (transistor or optoisolator). If the total for four relays is below the GPIO specification, you're OK. If not a single transistor buffer would do the trick, at the slight complication of reversing the relay state relative to the GPIO state.
Finding the specs is left as an exercise for the reader -- ask again if you get stuck or want your findings confirmed.
Re: Control multiple relays with only One gpio pin (mcp23017)
Posted: Fri Oct 26, 2018 12:35 pm
by cscuilla
Thank you. It seems the relays use 5ma to trigger. The rpi gpio can output 16ma so I'm guessing it can only handle 3 relays.
The MCP23017 output 20ma I believe so it looks like I may be able to use 4 relays on this.
Is it safe to assume that if I try it, and it works, then I am ok, and will not cause damage to the rpi?
Re: Control multiple relays with only One gpio pin (mcp23017)
Posted: Fri Oct 26, 2018 2:09 pm
by LTolledo
its the MCP23017 that will bear the brunt of the current surge, so it will get damaged first. Well, its cheaper to damage the I/O expander than the RPi itself
if you use 1 relay (controlled by 1 output pin of MCP23017) to control the other relays, you can control more than 100 (safe max 1000) other relays.
"1000 other relays" might be an overkill for your particular setup
Re: Control multiple relays with only One gpio pin (mcp23017)
Posted: Fri Oct 26, 2018 3:18 pm
by cscuilla
How would i use One relay to control the others..
Would i hold 5v in the relay, and then when that relay turns on, the 5v would be sent to the signal pin of the other relays?
@LTolledo
Re: Control multiple relays with only One gpio pin (mcp23017)
Posted: Fri Oct 26, 2018 3:35 pm
by Brandon92
What is the type of relais that you are using?
Re: Control multiple relays with only One gpio pin (mcp23017)
Posted: Fri Oct 26, 2018 3:42 pm
by cscuilla
Re: Control multiple relays with only One gpio pin (mcp23017)
Posted: Fri Oct 26, 2018 9:57 pm
by LTolledo
based on the information you provided this is what I have in mind....
that is..... if you dont mind.....

- relaying1x4.png (252.19 KiB) Viewed 1468 times
most relay modules will turn on if you ground their signal pins and will turn off if you provide 5v
the single relay may be replaced by a non-inverting transistor array (like the TBD62783APG) if you like to lessen the bulk