Ok i have a great idea (i think), but have absolutely zero knowledge on how to wire circuits properly and have only done a few of the starter arduino projects.

Using an Arduino Uno

My idea is simple i think. I have three float switches, one to turn the pump on, one to notify me the holding tank is low (illuminate LED), and another one to automatically shut off the pump as a fail safe.

If i can get this figured out I might try adding a thermometer, conductivity sensor, and a ph sensor to make it more of a reef controller than just water filling device.

So far, so good.Since you are using an AC pump, you probably need a SSR for AC.Sounds like the float switches are mechanical switches. You can use the internal pull up resistors with the switches, so no additional components on the sensor side.

Peter Brings up a good point. Basically all you have to do is turn on the pump when the low water float switch goes off. This doesn't require an arduino, just an AC powered relay.

However, if you do use the arduino, I would recommend adding in another fail-safe to prevent the pump from running too long, in case one of the switches fails in a 'low water' state, and makes the pump over-flow the tank when you aren't looking.

However, if you do use the arduino, I would recommend adding in another fail-safe to prevent the pump from running too long, in case one of the switches fails in a 'low water' state, and makes the pump over-flow the tank when you aren't looking.

^^ This. I've been reefkeeping for many years, and malfunctioning float switches are a major cause of death and devastation for a reef.

I've been rolling the idea of an Arduino-based ATO (Automatic Top-Off) around in my head for some time now (been reefing much longer than I've been Arduino-ing, so my ATO right now is just hard-wired 12VDC float switches and 120VAC relays). I'll share some of my thoughts:

1. Redundancy and failsafes: use the watchdog timer to make sure the Arduino doesn't hang. And, of course, at least two float switches.

2. Owing to the poor mechanical reliability of float switches, I've also be toying with the idea of using capacitive sensing for the water level. Depending on the sensitivity, it might even be possible to place the sensor on the outside of the tank wall rather than in direct contact with the water. Another option is an optical sensor through the tank wall like the commercial Tunze ATO uses, but I'm not sure that will work well if bacteria/algae start growing on the wall / snails etc start crawling in front of it. An IR distance sensor above the water aimed down at the surface might work and would not be subject to biofouling. (An ultrasonic distance sensor should also work, but, is too big for my little 1 gallon pico reef).

3. I would want my ATO to "learn" how long it has to run the pump for a normal topoff to complete. That way, even if both float switches stick "down", the ATO can disable the freshwater pump before the tank goes hyposaline (and overflows gallons of water onto the floor). I would also want the ATO to "learn" how long it goes between topoff events -- more on that later.

4. I would want a water change mode. In water change mode, the freshwater pump is disabled, but LEDs still continue to display the status of the float switches. That way, when I'm adding new saltwater, I know when to stop because the water level has reached the ATO point. This mode also prevents the "learning" algorithm from learning bad behavior.

5. Warning mode. If one of the two float switches is detected to be stuck, signal the user so (s)he can fix it before the other one sticks too.

6. "Limp mode". If both float switches are detected to be stuck (either up OR down for too long), fall back to topping off "blind". That is, wait the typical amount of time between topoff events (remember, it's been learning the average interval back when the float switches were working) and then go ahead and top off for the typical amount of time. Topoffs will not be precise, but they may save the tank from hypersalinity if, say, I am away on vacation for two weeks and the float switches malfunction the moment I walk out the door.

7. I might also give my ATO a water temperature sensor (so it can control the heater -- heater malfunctions are another major cause of death and destruction in reef tanks). But at this stage it's not so much an ATO as a full-blown reef controller. So, I might as well also add a 12V computer muffin fan and turn it on with a transistor for evaporative water cooling when the temperature is too high.

8. Since it's a reef controller now anyway, I'd also want it to control the lights. I could use an RTC, but it's a pain to set the date/time without an LCD, and I don't really want an LCD (just my "minimalist" personal preference). So I'd instead use an opto-isolator to detect zero-crossings of 120VAC wall power. Wall power is a very accurate 60Hz (or 50Hz depending on locale), accurate enough to use as a clock. Then I just need to tell my controller when it's dawn "now" and how long to run the lights.

Quote

Quote

and another one to automatically shut off the pump as a fail safe

I would use this to disconnect the pumps power directly i.e. not fed to the Arduino.

Almost no float switches* are rated for 120VAC. Float switches should be run off low voltage DC and the 120VAC load switched by a relay.

* Yes I'm sure there are some big stainless steel industrial switches that can switch 120VAC directly, but 99.9% of the cheap little white plastic ones used by hobbyists are not rated for it and the contacts will weld themselves "on" in a few days or weeks.

I don't know anything about keeping fish or reef systems, but I'm surprised that it isn't possible to get a reliable float switch and if that isn't possible then it seems to me that a solution based on float switches is not viable. Failsafe design should be used to cope with possible failures that might conceivably occur but probably won't, not with things that are expected to fail.

I only provide help via the forum - please do not contact me for private consultancy.

Thanks for the input everyone. New on here so i dont know how to quote everyone so i will try and cover everything as simple as possible.

First, I know i could make this without using an arduino, but I'm making this for my EMD class so i dont want it to be some junky thing. I also want to use this to learn how to actually do things like this in case i need it in my future.

I dont know if the water level tape would work with salt water so i would have to research that. I also would have to worry about corrosion and calcium build up on it as well.

I was thinking of having the float switch turn the pump on and keep it on for like 30 or so seconds and then start the loop over again. Otherwise i think it would constantly going on and off. This will also help keep the salinity at an almost constant value instead of waiting until the system absolutely needs water and then adding two gallons of fresh at a time.

for an extra measure of safety i was thinking of having a float switch at the highest point of water acceptable. like a few inches above the normal so it would at most only add an extra gallon or two.

I don't know anything about keeping fish or reef systems, but I'm surprised that it isn't possible to get a reliable float switch

Define "reliable".

A single float switch is pretty reliable. As in, thousands of cycles without malfunction. Good enough for many people in many applications.

But, in a reef tank (some of which contain, no exaggeration, years of effort and thousands of dollars of sensitive livestock), one failure in 10,000 is nowhere near acceptable. After losing a tank (I've lost two), you start thinking like NASA designing human-carrying spacecraft: 99.9999% reliability is the name of the game. I'll admit I'm a little more paranoid er, risk averse than many people though so I may go a bit over the top.

My current dual-float system works well enough, but I still have to clean the switches every month or two as a bacterial slime builds up and makes them sticky.

Quote

What are the capacitive sensing ones that go on the OUTSIDE of the tank?

I haven't seen any commercially. But it should be possible to make your own with two insulated wires glued parallel to each other over some length. Dunno if that length needs to be on the order of inches or feet though.

Quote

I dont know if the water level tape would work with salt water so i would have to research that. I also would have to worry about corrosion and calcium build up on it as well.

Yeah, saltwater is amazingly corrosive. I don't know that I'd trust the tape to hold up (and if it has copper inside, it's not getting anywhere near my water -- copper is deadly to most reef inhabitants!).

Quote

I was thinking of having the float switch turn the pump on and keep it on for like 30 or so seconds and then start the loop over again. Otherwise i think it would constantly going on and off. This will also help keep the salinity at an almost constant value instead of waiting until the system absolutely needs water and then adding two gallons of fresh at a time.

The cheap float switches I use are amazingly accurate. They have a sensitivity of a fraction of an inch, the water level stays very steady. Of course, I have a 1 gallon pico reef so you may get different results on a tank with more surface area.

My hardwired switches have no extra hysteresis, but the switches themselves do have a little bit of natural hysteresis. I have never experienced "flapping" or rapid on-off cycles except when I disturb the surface of the water. I'd say a few seconds of added software hysteresis for on-time and a few minutes for off-time would probably be fine.

I don't think it's necessary, but if you want more precise level control, use one switch for 'high' and one a few millimeters lower for 'low' and let your Arduino learn over time how to keep the water level steady (pump on time vs pump off time) without tripping either switch. The downside to this is you don't "exercise" the switches in normal operation so they're more likely to stick when you need them the most.

Or you can use an ultrasonic distance sensor aimed down at the surface and bypass the whole issue completely. I suspect an IR sensor would work too, but I'm not sure if it works well on the shiny water surface or not.

Quote

for an extra measure of safety i was thinking of having a float switch at the highest point of water acceptable. like a few inches above the normal so it would at most only add an extra gallon or two.

Having a third switch as a failsafe, mounted higher than your two main switches, is a good idea. LarryD's suggestion of having it hardwired (through a relay) and not through the Arduino is even better.