How can I drive a latching relay with a single gpio?

Hi,

I have a project where I'd like to turn my lights on/off remotely with a switch that can alternate the state of the circuit. A simple 3-way switch along with an SPDT relay will do the trick there however I want to create a power-efficient design. The arduino will be ~70feet away and I will provide power to the relay through a centralized transformer & some wires.

My ideal input in the gang:
*1 wire for GPIO (on/off)
*2 wires to power @ 5VDC
*3 wires from the main 120 VAC (Neutral + HOT + GND)

I'm using a latching relay for power efficiency and ideally, I don't want to use 2 wires per relay to control the relay. I understand that I can use a 2 coil relay and invert +/- to alternate the state of the relay. Alternatively, I could use a single coil with some transistors to achieve the same thing, but I struggle to figure out how I could do this with a single pin vs 2 pins.

I don't particularly care what state the relay is in. I only really want to XOR (flip) it's state. ie: If it's in NO, I'd want to switch it to NC and vise versa. I already have a circuit that will detect the output coming out so I can easily control it by reading the result out and flipping the state with the Arduino if that's not what I wanted. I've taken a few EE classes over a decade ago so I'm a little rusty on some of these concepts. Vaguely speaking, I'd imagine that I'd want to detect a change in voltage on the GPIO (presumably I can do that with a transistor?) and depending on the state of the GPIO, I'd either send a burst to set or reset (2 more transistors?).

I Googled for all I could and I couldn't find an example of how I could wire something like that and atlaest what I read in a few forums seem to suggest that this is totally possible. Fewer parts is a plus as well, but making sure that I don't consume power while the appliance is on/off by the relay trumps that.

Thanks

Hi,
Show us the exact relay you have (point to data sheet?)..

The output is tri-state, so it can be HIGH, LOW, or HI impedance. Of course you would need a few components on the other end to translate this to and drive the relay. I think you have the additional obstacle of 70ft of wire to handle as well. That's a long way.

Perhaps a drawing of the proposed wiring would be good

Sounds like you want an alternating relay, I've used them in industrial work but don't know if they are made in low voltage types. When powered current went to terminal "A", at the same time a solenoid was pulled in, when power was turned off, the sol dropped out, switching to terminal "B". Next on cycle sent current to terminal "B" and so on. Contacts are switched on the falling edge of power input.

terryking228:
Hi,
Show us the exact relay you have (point to data sheet?)..

Yes I'm sorry. I'm looking at two possible choices there:

outsider:
Sounds like you want an alternating relay, I've used them in industrial work but don't know if they are made in low voltage types. When powered current went to terminal "A", at the same time a solenoid was pulled in, when power was turned off, the sol dropped out, switching to terminal "B". Next on cycle sent current to terminal "B" and so on. Contacts are switched on the falling edge of power input.

I believe that's what I'm looking for, but I can't find any that are low voltage.

tinman13kup:
The output is tri-state, so it can be HIGH, LOW, or HI impedance. Of course you would need a few components on the other end to translate this to and drive the relay. I think you have the additional obstacle of 70ft of wire to handle as well. That's a long way.

Perhaps a drawing of the proposed wiring would be good

I've done my research on that front. 70 feet is perfectly fine because I plan to use an opto-coupler which will require a very small amount of current to be triggered. The power for the relay is going to come from a separate 5VDC source also at 70" but that's also ok because both relays are guaranteed to trigger at 3.X Volts so no worries there. Even with 0.5A, my voltage won't drop that low using 18 gauge copper wires. I expect to get between 4-5VDC to the relay depending on how far they are from the source.

I could post the entire circuit, but it would be more confusing than anything else. I think it's easier to simply think of what I'm trying to do as trying to use a latching relay triggered by a circuit which is closed vs open.

Use CAT5 cable for the low voltage, plus a mains cable. That gives you plenty of options, CAT5 is
cheap and its resistance properties are well defined - you can common-up multiple wires for more
current handling.

Otherwise your only option is adding smarts at the relay end (another Arduino) and talk serial
to it.

Even if you don't care about the state, you will want to be sure that when you send a signal it switches the relay off or on, regardless of what state it is in.

Relays may switch off for whatever reason (short power interruption), so when you think you switch it off, you switch it on. Asking for trouble.

Power supply: why not a small 5V adapter at the relay? You have mains power available. Just make sure you connect the live wire before the relay to that adapter. Then you need only two wires to control the relay, no need to string a power supply as well.

For the switching, indeed use the three-state ability of the poles. Don't skimp on signals, use 10 mA or so, and require at least 5 mA for it to even react. That makes your setup much more robust - that long wire is an antenna, picking up lots of noise.

Make it so that a HIGH signal switches on the relay, and a LOW signal switches it off. As you have a latching relay, a pulse of 0.1-1 seconds or so will do just fine, after which you can set your pin to INPUT and have it not supply any current. Depending on the relay all you probably need is two diodes on the other end to separate these signals.

If you used a SPCO relay you can achieve this by using the traditional 2-switch control of a staircase light.

Nothing fancy required.

Allan

You may be powering the relay separately, just realize that the signal needs a ground, so....

Actually I think I may have solved my problem, but I still need to fully review all of the details. I'm currently thinking of taking the output from the optocoupler and feed that into a a D-FlipFlop (feed the value into the clock and keep the data at HIGH) with the output going into the relay. I may need a few transistors to properly address the power requirements, but in theory I think that this should work with a few components.

MarkT:
Use CAT5 cable for the low voltage, plus a mains cable. That gives you plenty of options, CAT5 is
cheap and its resistance properties are well defined - you can common-up multiple wires for more
current handling.

Otherwise your only option is adding smarts at the relay end (another Arduino) and talk serial
to it.

Yah CAT5 is definately my wire of choice here :).

wvmarle:
Even if you don't care about the state, you will want to be sure that when you send a signal it switches the relay off or on, regardless of what state it is in.

Relays may switch off for whatever reason (short power interruption), so when you think you switch it off, you switch it on. Asking for trouble.

Power supply: why not a small 5V adapter at the relay? You have mains power available. Just make sure you connect the live wire before the relay to that adapter. Then you need only two wires to control the relay, no need to string a power supply as well.

For the switching, indeed use the three-state ability of the poles. Don't skimp on signals, use 10 mA or so, and require at least 5 mA for it to even react. That makes your setup much more robust - that long wire is an antenna, picking up lots of noise.

Make it so that a HIGH signal switches on the relay, and a LOW signal switches it off. As you have a latching relay, a pulse of 0.1-1 seconds or so will do just fine, after which you can set your pin to INPUT and have it not supply any current. Depending on the relay all you probably need is two diodes on the other end to separate these signals.

I can validate that the relay changes state when I send the signal over because my circuit is also equipped with a mains detector that is fed back into the Arduino. Not only can I detect whether or not the end result of the power is on/off (including any manual switched added), I can also detect that it does indeed change and I can also force the power on or off (again by reading the output).

Good call on noise control. I'll definitely keep that in mind. The HIGH/LOW state was also what I was thinking of :).

allanhurst:
If you used a SPCO relay you can achieve this by using the traditional 2-switch control of a staircase light.

Nothing fancy required.

Allan

Excuse my ignorance, but what is a SPCO relay? (S)ingle (P)ole... CO? Google wasn't effective at helping me sadly.

INTP:
You may be powering the relay separately, just realize that the signal needs a ground, so....

I'll have ground from the main line.

ti_chris:
Yah CAT5 is definately my wire of choice here :).

So unshielded.
Best have a capacitor on both side to filter out the noise (also on the Arduino side to prevent noise spikes from affecting your system).

ti_chris:
I'll have ground from the main line.

You need the ground from your Arduino to extend to the relay side. That is your reference for the signal itself. Don't try to extend power from Arduino to there to control your relay - not only does it negate the whole optoisolation, the resistance of the long wire (it's a return even, so 140 ft of wire total) may drop the voltage so much that you don't have enough left to switch the relay itself.

That signal needs to make it back to the Arduino, what we in the biz call a 'circuit'