Urgent electronic problem (drive pump with 2 switches)

Hi folks,

Not really Node-RED related, but need some help...

Lots of water daily in the basement of my mother in law, due to the heavy rainfall.
Father in law died recently and his self-made pump mechanism does not work anymore.
So I wanted to replace it tomorrow morning, based on some Aliexpress stainless steel float switch from Ali. Something like this:

The switches can float up and down like the red arrows indicate.
When a switch floats up it is OPEN and when the switch goes down it is CLOSED.

I would like to control this 4 channel 5V relay board (to control the pump):


When the upper switch is open, the relay should be closed. And when the lower switch is closed, the relay should be opened again:

Is this possible using a "simple" circuit, or am I doomed to fail tomorrow morning?
Unfortunately I don't have much electronic components available...

Thanks a lot!!

BTW I did not have a chance in advance to have a look how much current the pump consumes. The relais have a maximum of 10A. Suppose the pump uses above 10A: can I wire two relais in parallel to divide the current, or does this make no sense at all?

Sure, but i would use inline 10A fuses on both relay outputs in case one of the relays fail (or is of sufficiently high resistance so as to cause more current to travel down one than the other)

1 Like

A 10 amp pump would be large what are you expecting to pump?
You can turn the float switches 180 degrees to reverse their operation, then you could use a standard contactor/relay no electronics required.

But I would just go with a standard sump pump with built in float switch, or if you want to use the old pump use a 240v float switch, on a RCD circuit.

In your diagram what would happen if one float failed?
They may be stainless, but they would get salt build up and may jam.

As stated you can use two relays but I would consider that a stop gap rather than long term solution. They will never close or release at same time so you will get arcing and definitely not get full life out of them. I personally like SSR's and you can get them to run at 3 volt and carry 40 amps or more. But short term, they will work. Not sure what kind of pump you are using , most small volume pumps I have seen would be under 10 amps. Should be a data plate on it somewhere.

Well it should only pump the water 2 meters higher. So yes indeed it might not use that much. Which would even be better.

Yes I did also think about that. For the upper one that would be no problem, because there is enough height. But when you turn the bottom one upside down, then the rest water level would be too high. The available depth of the barrel is very low unfortunately...

That is a good one...
What a pitty that you are not allowed to curse on Discourse...

Ah yes of course. Damn...

Yes, but it is too far driving for me to check right now. Will only see it tomorrow unfortunately.

By reading all this, it seems like a bad idea at all.
I assume I will need to buy a new pump with a build-in float switch.
One that doesn't need much height, and results in few rest water.

Thanks all for providing me some practical tips on such a short term!!!!

The rest water level is set by the top float in your diagram as pump will switch off as soon as the water falls below top float. If you want the bottom to stop pump the floats would be wired in parallel, also that would mean a single float failure would just change rest water level, and act as failsafe.

I cable tie the 240v float to the top of a brick, hanging over edge, with just 1 inch of flex. the pump stops at about 2-3 inches and starts at about 5-6 inches. Been running now for 10+ years no issues.
You can buy just the float switch if you have a pump already

1 Like

If it's a heavy duty pump, the relays will probably not last long without suppressing the spike (back EMF) created by the pump motor.
Back EMF can cause rapid arcing between the relay contacts, leading to quicker degradation and potential welding of the contacts together.
You may wish consider adding a snubber.

1 Like

On the contrary, I think your idea will run for long enough to get a few more bits together. Most pump systems have a SPOF( single point of failure), the float switch, the pump motor, and on. Carry on with your plan but keep in mind it IS temporary.

1 Like

If you would have some time o draw a quick scetch of such a wiring diagram, that would really help! I did some drawing earlier this evening for both a serie and parallel circuit. But none of them seemed to do what I wanted to do. Most probaby I did something incredible stupid wrong on my paper :flushed:
And why that would be failsafe...

The big question is if you plan on wiring the float switches into the power circuit, what are the switches rated at?

The fail safe would be that in parallel the float switches would still start pump if one failed.

If you wanted to use the relay board in your first post, I would need to see the spec as I am unsure as to how they are triggered and if resisters may be needed, @zenofmud and @dynamicdave are the electronic experts I would want to hear from on that board.

I can offer diagrams for standard 12v dry contact relays (eg shellies) or 240v float switches that you would have on standard sump pumps.I doubt your stanless floats are rated for 240v but should be fine on 12v.


Not to be critical but as shown when the bottom float "makes" the pump will run thus the top float will never engage. This would make the pump short cycle, but doable although not what I think he wants. The logic is when both floats make the pump runs until the bottom falls. The floats make when down so you'll have to invert (maybe) that logic to get what you want. Let's call the bottom float A, top B. When A and B make run pump till A opens. Then reset.

1 Like

I ginned up a quick flow and can't test but I think this does what you need. You'll need to get the floats wired to a Pi pin and I don't know what those look like or which ones. I use a board that looks like what you have and it uses inverse logic (0) to activate pins. You'll need to sort that out I didn't use inverse logic on the output but I did account for the inverse logic on the floats. (again I think), I'm not a coder I'm a hardware guy by training so take this flow with that in mind.

[{"id":"6b6734f989360c42","type":"tab","label":"Flow 1","disabled":false,"info":"","env":[]},{"id":"14cee1b989ea917a","type":"comment","z":"6b6734f989360c42","name":"float A bottom","info":"","x":250,"y":140,"wires":[]},{"id":"df3075a8e9c8f45e","type":"comment","z":"6b6734f989360c42","name":"float B top","info":"","x":240,"y":300,"wires":[]},{"id":"d6446b1fcaecaed2","type":"rpi-gpio in","z":"6b6734f989360c42","name":"","pin":"23","intype":"tri","debounce":"25","read":false,"bcm":true,"x":250,"y":200,"wires":[["cfefdc08ed2e98e7"]]},{"id":"7dac2034729d6911","type":"rpi-gpio in","z":"6b6734f989360c42","name":"","pin":"18","intype":"tri","debounce":"25","read":false,"bcm":true,"x":250,"y":340,"wires":[["27fcc2d3c14d6bc6"]]},{"id":"a2104622be8e456d","type":"rpi-gpio out","z":"6b6734f989360c42","name":"","pin":"24","set":"","level":"0","freq":"","out":"out","bcm":true,"x":780,"y":260,"wires":[]},{"id":"3dfa1aee6a924783","type":"comment","z":"6b6734f989360c42","name":"to motor","info":"","x":780,"y":200,"wires":[]},{"id":"cfefdc08ed2e98e7","type":"function","z":"6b6734f989360c42","name":"Float A","func":"let A = msg.payload;\n\nif (A == 0){\n    msg = {\n    payload: 1,\n    topic: A,\n    }\n}\nif (A == 1) {\n    msg = {\n        payload: 0,\n        topic: A,\n    }\n}\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":420,"y":200,"wires":[["68fea6eb23f07df8"]]},{"id":"27fcc2d3c14d6bc6","type":"function","z":"6b6734f989360c42","name":"Float B","func":"let B = msg.payload;\n\nif (B == 0){\n    msg = {\n    payload: 1,\n    topic: B,\n    }\n}\nif (B == 1) {\n    msg = {\n        payload: 0,\n        topic: B,\n    }\n}\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":420,"y":340,"wires":[["68fea6eb23f07df8"]]},{"id":"68fea6eb23f07df8","type":"function","z":"6b6734f989360c42","name":"Pump Logic","func":"\nvar FloatA;\nvar FloatB;\nvar PumpOn;\n\nif (msg.topic == \"A\"){\n    context.set(\"FloatA\",msg.payload);\n}\nif (msg.topic == \"B\") {\n    context.set(\"FloatB\", msg.payload);\n}\n\nFloatA = context.get(\"FloatA\");\nFloatB = context.get(\"FloatB\");\n\nif (FloatA == 1 && FloatB == 1){\n    //turn pump on\n    PumpOn = 1;\n    context.set(\"PumpOn\",PumpOn);\n}\n\nif (PumpOn == 1 && FloatA ==0){\n    //turn pump off\n    PumpOn = 0;\n    context.set(\"PumpOn\",0);\n}\n\nlet Output = context.get(\"PumpOn\");\n\nmsg.payload = Output;\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":590,"y":260,"wires":[["a2104622be8e456d"]]}]
1 Like

Hi guys,
seems you have been working hard while I was sleeping :heart_eyes:
Thanks for the assistance!!

I managed to lend a pump from my dad temporary which does what I need. Which buys me some extra time to think about this decently.

Yes indeed they are for low voltage only. That is why I had suggested the relay in my original post, so that the relay could toggle the 230V signal. Seems I wasn't very clear in my post. Normally I try to draw a wiring diagram, but I was a "bit" out of time last night...

Ah you used a Shelly. Cool. I like Shellies for their simplicity...
I had also been looking at Shellies last night, but I thought I needed a Shelly 1L because that has 2 switch inputs:


And that I needed to put some logic inside the shelly (using Shelly script or whatever) to fit my needs. Although I was not sure what was needed... But since I didn't have one of those Shelly 1L devices, I started this discussion to solve it another way.

I still don't understand how two switches in parallel can solve this :flushed:

  • When the water rises: the bottom switch opens and the top switch is still closed, the pump should be off.
  • When the water drops: the bottom switch is still open and the top switch closes again, the pump should be off.

So both switches have the same state, but the pump state should be different. How can you achieve that with a parallel circuit? Think I am getting nuts...

The pump should stop when the water drops below the bottom switch, so when the bottom switch closes again. Since you and @E1cid have a similar remark, I assume my drawing is completely wrong. So I am really getting nuts...

Thanks for your flow! Will have a look tonight at, because I need to start driving to my mother in law to get things done today. Will tell here how this community tried to help her, by explaining me how a simple switch works :joy:

I explained in earlier post that if you wire in series the water level will only go as low as picture 2 and 3,. This is due to fact that pump will turn off as soon as top float closes.
Scratch that i did not see the difference in 2 and 5.

The shelly 1L does not have dry contacts so please check knowledge base before purchase

Sorry to butt in, but something is confusing.

You have 1 or 2 pumps?
I think it is 1.

The two switches (aka sensors).
One is low down (physically)
The other is higher.

There is a problem with INFLOW and OUTFLOW.
Inflow is how fast the water in coming in and Outflow is how much water the pump can pump.

Outflow MUST BE GREATER than Inflow - or you are going to have/get more problems.

I fear you may be confused - and fair enough if you home is getting flooded.

Given the pump can handle the inflow:
You need hysteresis for the pump, as it is not good to run a water pump dry.

Put the lower of the switches/sensors near the floor.
You should not put it at the bottom as the pump may run dry.

Put the second sensor higher. Say...... 10cm. 4 inches I think. (I'm metric)

The logic should be like this:

while (switch1 == active)
    if (switch2 == active)
         turn pump on;
turn pump off

This way:
your floor will get wet - sorry, but that's how it is.
When the higher sensor is activated the pump is turned on.
(All being good it will pump out the water faster than it is coming in. But we've covered that)
When the lower sensor then detects the water is gone, the pump is turned off.

Hope that helps.

Good luck.

Hi @BartButenaers,
I may have a solution for your script:
Need a flag:

let flag = false;

if (!sw1 && !sw2) {
  flag = true;

if (flag && sw1) {
  flag = false;

output = flag;

sw1 -> Float Low
sw2 -> Float High
output -> Pump

Hi Bart, I'm guessing that you were wishing to avoid using a pi or other microprocessor to achieve this, but you just wanted to use the bank of 4 relays??
If so, consider the diagram below.

Water level below bottom sensor
Both High & Low relays are not energised, so pump not operating.

Water level above bottom sensor
Low relay is then activated, but as the Latch relay is not activated, the output relay & pump remains inactive.

Water level above top sensor
Both High & Low relays are activated. The High relay activates the Output relay, and energises the pump.
The High relay also energises the Latch relay, allowing the current to also flow through the Low relay into the latch relay and also activate the output relay.

Water level falls, and the high sensor no longer activated
The High relay is not energised, but because the latch relay is still energised, current continues to flow from the Low relay, through the latch relay, the output relay, and keeps the pump running.

Water level falls below Low sensor level
The Low relay is then not energised, so the latch relay is no longer 'latched' and no output to the pump.


I believe you should use NC for High Relay and Low Relay because the float logic is reversed

I've never used a float sensor so wasn't aware, however easily sorted!
I've updated the schematic accordingly.

EDIT see this post below for plan B

1 Like