Arduino Water Controller
Back in 2012 I was on a learning spree with microcontrollers, electronics, and Arduino. After blinking LEDs, making buzzer sounds, and controlling devices I was ready to take the next leap. Around the same time I had a problem that needed a solution. At the time there weren’t many inexpensive PLCs (Programmable Logic Controllers) as there are today, so I decided to investigate whether or not it would be possible to use the Arduino as a mini-PLC to solve this problem.
The problem at hand involved automating a simple but tedious manual process. In Brazil where my wife’s family resides, my father-in-law had two freshwater tanks that were being filled with one well/submersible well water pump. One is for the business and the other for their adjacent home. Because of concerns of drought periods, there had to be some logic in controlling it, where the system would not let more than one filling operation happen at the same time.
The system I created with the Arduino UNO controls water flow with 1 pump, 3 hydraulic solenoid valves (irrigation valves), 2 water tanks, 2 water level float switches, and 1 manual switch. Conditions are set so that the pump is only feeding one source at any given time; to not choke the water supply or overload the pump. In addition, I added a manual switch that could actuate the pump for misc. operations. Once the project was complete I brought it to my family’s house in Brazil. And if you ever want to see a TSA agent do the double-take of his life, it was when he put the controller through the x-ray scanner at the airport!
The way the logic is written is as such;
If two switches are low at the same time, the system will hold the others until the first one is high again. This programming could be expanded to a seemingly infinite number of valves as needed. The Arduino proved to be a very capable and easy way to handle the IO (Inputs and Outputs) but it also proved to be difficult for use in the real world. For one thing, I experience inconsistent AC flyback and ghosts in the system, causing the microcontroller to randomly reset with no pattern. Modern industrial PLCs are built to deal with large inductive loads and to minimize this type of ‘noise’, but despite my best efforts the Arduino is not. I enjoyed this project greatly and it taught me a lot. The Arduino is a great development platform and while it has its limits, it’s an incredibly powerful piece of hardware for the price. Please check out my system overview as well as the deep review for a more thorough explanation of how it all worked.
I have posted my code below for others to learn and share. Please contact me if you have any questions or concerns.
Some of the items below contain affiliate links which help this website.
You can find the arduino uno and other arduino boards/supplies in great abundance here:
I receive many of requests for arduino/electronics information and where to read up on it. I’ve listed my 4 top favorite books for this topic, and the last two links particularly Make’s book is absolutely fantastic for step by step/hands on electronics learning.