Water Softener Dosing System

I have a Water Softener that I would like to have a cleaner added to right before regen. I am using an Arduino Uno with a DS3231 RTC and a peristaltic pump to move the chemical. My problem is I can't come up with a way to time the pump to activate.

The water softener will go into a regen cycle every 3 days at 3 AM. Is there a feasible way to set up the Arduino to activate the pump every 3 days just before 3 AM? Or would it be better to come up with a way to sense the regen cycle and have that trigger the pump? When the regen starts the brine tank needs time to fill with water (approx. 10 minutes) so adding the cleaner during this time would not be an issue.

Any ideas are welcome. I have been tinkering with Arduino for a while but I will not claim to be great at it. So with that said I am open to any and all help anyone has to offer thanks in advance!

Yes of course. The RTC will provide date and time data so triggering an action every 3 days at a fixed time will be easy

It seems to me that if the cleaner is to be added before the regen then it is pointless detecting that the regen has started and then adding the cleaner

Hello, so my issue with that is I'm just not sure how to track when 3 days have elapsed I thought of using an "int" to use as a counter but just not sure how to implement it. I have used various sensors relays etc but honestly, RTC is the hardest thing to use for me not sure why lol. Also, it just occurred to me that I didn't mention why it has to be based on 3 days. If a manual regen cycle is initiated I will need a simple way to reset the counter to zero if a manual regen is initiated.

When the cleaner is added is a bit flexible when the softener goes into regen at 3 AM the brine tank must fill with water. It takes a minimum of about 10 minutes to fill so as long as the cleaner goes in during that 10 minutes all is well. I'm sorry I should have mentioned that it was flexible in the OP I will correct that.

The RTC will tell you the date when the cleaner is added. Every time that date changes a day has passed. When 3 days have passed it is the day when the cleaner should be added. When the RTC time is nearly at 03:00 on that day then pump in the cleaner

One problem with implementing this the other way is how are you going to detect the start of a regen ?

Seems like the only problem with implementing it the other way.

If @lukey385 can find a way to get that information, it would probably be better to use that signal rather than just blindly do it every three days at 3 AM in the morning.

How accurate and reliable is that controller? What if it doesn't do it for some reason, or drifts and becomes late or early WRT standard time?

It would be simpler to do it as necessary, that is when the thing is actually regenerating.

What does regen consist in? Almost anything it does could probably be safely and easily developed into a digital input for the cleaning pump controller.

a7

+1 for this approach

Ok, so it does seem like the best solution is just to trigger off of the regen cycle, not RTC. The water softener controller is a bit old and its internal battery is weak so any power outage of more than 30min causes the time to drift (it used to remember the time for a long time after a power outage when it was new but now any lengthy outage causes the controller to lose track of time).

So let me explain an option I have for detecting the regen if anyone has a better idea I didn't think of please add it. The only possible way of a direct connect to the regen I can think of is to have the Arduino watch a small SPDT switch. Every time the softener goes to regen the controller powers a motor that turns a water valve there is a little trigger switch that slips in the groves of the valve and counts as the valve turns so the controller knows what setting the valve is on. On regen start, the valve goes to Backwash for 2min, then Rinse for 1min then it goes to fill for about 10min. Then it goes to Drain for 118min then it goes to Backwash again for 3min then to Rinse for 5min.

My guess is just for simplicity the best way to accomplish this would watch the switch which already uses a 5V signal and when the switch is activated that would trigger the dosage. Still, then I would need to ignore the rest of the activations as the valve moves through the other settings. Thankfully that is very predictable it follows the same pattern every regen. I would need Arduino to ignore the switch for about 137 minutes total after the first trigger. I could use an If statement to detect the first switch activation run the dosing pump, then delay for 137 minutes. Would that work? Or perhaps is there a better way?

Hopefully, I explained this well if any clarification is needed to feel free to ask I am happy to attach pictures videos or explain anything that will help. As always any ideas, suggestions, or problems are welcome.

That would work, either literally by using a call to delay() with an appropriate number of milliseconds or other ways of delaying, effectively, without actually using dealy().

If there are other things to do, the more sophisticated ignorance would be preferred - your device could play a game of tic-tax-toe with you while it was ignoring the signal.

Can you say a bit more about what you know of the swtch beyond it being already a matter of 5 volts?

a7

You mentioned power outages earlier - do you need to worry about a failure during the regen cycle?

Yes I'm sorry I had a link to the switch but accidentally removed the link when I was editing that post here is the link. Switch The link is to Mouser which should have any info you need but if you need something more specific just let me know.

No, power outages are rare here but the controller on the softener is already capable of dealing with preventing issues with a power outage by using mechanical safety features like a float in the tank that will shut off the water if the power is out.

Yes, sry, I meant how is the switch involved electronically? You said "already uses a 5V signal", but that leave quite a bit of wiggle room.

A logic 5 volt line that is pulled to ground by the closing of the switch contacts would be useful.

So might other things described as 5V signals.

First concern is to avoid damages to the system you seek to spy on in this manner.

a7

So I know this is going to sound like a noob question, but how could I tell if that switch is pulled to ground without taking it apart and attaching it to the Arduino? With a voltmeter on the 2 legs of the switch the switch is open in reads -5V if I swap the leads of the volt meter I get 5v if I close the switch the reading becomes zero

NP, we all born noobs, so.

Do you have a multimeter? And yer brave enough and know how to use it to poke around a bit?

When the system is on, measure the voltage at each of the two switch contacts, both measurements with respect to the system ground.

Do that with the switch both open and closed.

Maybe: you read 0 and 5 volts with the switch open, and 0 volts with the switch closed. 0 and 0 obvsly, I hope, because a closed switch should have the same voltage on both sides.

The data sheet shows this as an SPDT switch, so measure all three voltages in both open and closed condition.

a7

Ok so I’m confused if I put one lead of the volt meter to the first plug on the switch and the other lead on the second used leg I read 5v switch open if I close the switch I read zero now if I use one lead on the ground of a plug-in and the positive lead of the volt meter on either of the first two leads they both show 1v AC with switch open or closed but the third leg shows 1v ac with switch open and zero with switch closed am I doing something wrong or it that weird?

Yikes. Do you mean the ground wire of an AC plug?

Ground in the context I used it was meant to be the ground level of the device the switch is wired to, like the ground on you Arduino board is not the ground of the AC plug, necessarily.

Sry I wasn't clearer.

So look at the circuitry the switch is connected to, and find its GND ground level, usually not too hard to discern.

a7

Yes, this is what you would expect. The switch is connecting 5v to ground and the controller senses that change.

You should be able to run a wire from the +5v side of the switch to an Arduino input pin and poll for a change from HIGH to LOW. I think the Arduino pin should use INPUT_PULLUP. The Arduino ground will need to be connected to ground of the switch.

Are you absolutely certain you measure 5v DC and not AC on the switch?

I would bet you are right, but there is not sufficient evidence for that assertion at this time.

I'd also be reluctant to use a pullup, internal or not. Without knowing more.

If the switch does turn out to be in fact wired as we suspect, I wonder out loud if using an analogRead would be better.

Also I mention using an optoisolator with the LED driven by a transistor. There, I mentioned it.

All solutions proposed involve uwing a common ground.

a7

Ok @alto777 not sure why I didn't think to do this sooner I contacted the manufacturer of the Water Softener and asked for a detailed wiring schematic this is the best they could do they told me. But I will upload it now. So the switch I have been working on is labeled Position Switch. If you would like me to test using anything specific just let me know. The only wire I see specifically labeled as Ground is a wire heading to the turbine if I use that as my ground I read the following on the switch.

C lead on the switch 0V switch Open or Closed is the same
"NO" lead reads 5V with the switch Open and reads 0V with the switch Closed
"NC" lead reads 0V switch Open or Closed is the same

Sorry, it takes a while to get back to you all I work the night shift.

OK, now I am quite sure that with a common ground, you can take the contact that goes from 5 volts to ground and use that as an input to your Arduino.

No pullup is necessary or advised, by me anyway.

A small resistor, say 4K7, in series, that is to say instead of just a wire, is also not necessary but might offer a small degree of protection should the end of the wire/resistor at the other end go somewhere it shouldn't on accident.

But you won't make any accidents, I just mean be careful in there.

The software can be 100 percent written and perfected before you get anywhere near the device you seek to modify. Use a pushbutton as proxy for the switch on the machine, and use INPUT_PULLUP during the dev phase, or use a real pull-up resistor and INPUT pin mode.

You can get the software 100 percent written and perfected without buying anything, check out the amazing

wokwi online Arduino simulator

HTH

a7