FNG-Can it do latching relays with switches

Trying to set up a latching relay that will hold 12VDC + and - till two switches are tripped then it will reverse the 12VDC polarity and hold the volt till both switches are turned off, so it can run a 12 volt linear actuator.
The system will be running off a 12VDC battery with a solar panel hooked to the battery to charge it.
I sure the Arduino can do this simple task but I don't know how to start writing the code, Can someone help with the code and I can build the electronics.

Latching relays are complicated to control. What's the purpose of moving a linear actuator either left or right, without ever stopping it?

Please try to describe your problem, not a partial solution.

Is it going to be lifting a lid on a water tank. When the tank is full the lid will open and when the tank empty the lid will close. I have a float switch at the top and bottom. The linear actuator has a switch to stop the motor when it is fully open or fully closed. Need a code that would hold power to a relay till both switches are on then go 0 volt when both switches are off.
I have been doing this with 4 relays but they seem to draw a lot of power and trying to make it easier to install
Thanks for your time

I use latching relays all the time. very simple once you figure them out, all you do is send a pulse and they change state.
depending on your latching relays, you either have one coil and have to reverse polarity, or you have two coils, one to set and one to re-set.

I typically use the Magnecraft, 755 series.DPDT for control relays.
the lighting contactors have a mechanically held action.

your post is confusing. a magnetically held latching relay uses no power, but you ask for code to hold power.

may I respectfully, request you go back to square one and tell us what you are trying to do ?
if you have two floats, then the Arduino 'sees' those values

top float signals tank full,
signal out to actuator. close lid
bottom float signals tank low
signal out to actuator to open lid

it would seem that only sending power to the motor, and in the right direction, might be easier than adding relays.
a simple H-Bridge is used to drive a DC motor forward or reverse.

this is definitely a case where a drawing of your tank, floats and actuator would help out.
also, data sheet on the actuator.


This is how I have the relays setup now.
The diode holds the relay high till both of the switches is turned flipped in one way. With this design the top switch has to be NC for it to work.
I will draw the tank and switches tomorrow morning, it is getting late here.

Maybe This will work for the picture

Please post a circuit schematic diagram, not a wiring diagram. For the functionality it's important to understand what's inside a block, and how those internals are connected.

Your goal can be reached with only relays. Then the actuator is powered to open the lid when tank_full is on and lid_open is off. This motion stops when it forces lid_open on.
The equivalent to close the lid, when tank_empty is on and lid_closed is off.
(Assuming tank_full and tank_empty stay on long enough, to keep the actuator moving until it reaches lid_open or lid_closed).

In code you wait for tank_full or tank_empty. On tank_full set the motion direction to Open, and power the actuator until lid_open goes on. On tank_empty set the motion direction to Close, and power the actuator until lid_closed goes on. The power and motion switches can be ordinary relays or a H-bridge.

With latching relays the logic has to be modified, to start Open on tank_full, and stop Open on lid_open. Similarly start Close on tank_empty, and stop Close on lid_closed. Care must be taken to toggle the relays only once, so that e.g. tank_full and lid_open, when on at the same time, do not try to start and stop Open at the same time.

Here is the circuit schematic diagram, hope this helps with the understanding.

DrDiettrich:
In code you wait for tank_full or tank_empty. On tank_full set the motion direction to Open, and power the actuator until lid_open goes on. On tank_empty set the motion direction to Close, and power the actuator until lid_closed goes on. The power and motion switches can be ordinary relays or a H-bridge.

This is exactly what I need for the code and if there was not any switches active for 10 min. then it would release the relays till a switch was tripped.
Can this be done and do I need to pay for someone to write the code, I seen, on the forum where people will write the code for money??

One more thing, This will be close to corrosive chemicals and it would be best to enclose the board and electronics epoxy. Is there any issues with enclosing the Ardiuno in epoxy.

You can encase in epoxy as long as the epoxy is not conductive.
I've used thermally conductive epoxy high temperature setting with automotive rated parts, Atmega328P-15AZ.

This stuff needs to be baked at low temp (65C) for 2 hours to cure. Or wait a really long time.

Thanks CrossRoads I will order some right away if I can get someone to write the code and get this working

TrellBuilt:
This is exactly what I need for the code and if there was not any switches active for 10 min. then it would release the relays till a switch was tripped.
Can this be done and do I need to pay for someone to write the code, I seen, on the forum where people will write the code for money??

what you want can be done without too much trouble.
your choices are simple. learn the arduino language and program this yourself, or hire someone to do it for you.
doing it yourself will offer a greater knowledge and more ability to change things as you desire.
also, once you find the arduino as a solution, you find many other projects that could use the automation.
I do not know your experience, but this could take a dozen hours, maybe dozens, if you have to learn electronics in the process of learning software.
if you hire someone, please, have them review the whole project, all chemicals, etc and it is a very good chance they will offer things you have not thought about. I am pretty sure it would be much easier to use an H-Bridge than to use latching relays. locate your electronical bits remotely and not need to protect them from the chemicals.
but the best thing is that you could get this working in a day or two.