DIY Modular Water Automation System for Multiple Water Tanks

Published  February 25, 2022   0
S Santhosh Sivan D
Author
Water Automation System using ATMega328

There are many reinventing wheel scenarios is happening in the field of water tank level controllers. It is decades old project now, still, there is not a single product to solve one main problem. There are products in the market with a maximum of 2 tanks (not exactly), 1 tank as a sump, and 1 tank as OHT. For multi-tank, multi-pump users, there is a serious issue known as valve operation. The valves had to be frequently operated (either opened or closed) for the water to go to another tank when the current one is filled and so on. This is the main problem that is faced by the Multi-Tank, Multi-Pump, and Multi Sump system owners. Don't worry anymore, we have a solution. We designed and developed our indigenous Modular Water Automation System. It can control a maximum number of tanks and pumps available in any domestic and commercial house or office. We had tried and tested up-to to 4 Individual Tanks and 1 Pump (Maximum control of tank and pump is not limited to 4) at the same time using our one and only Modular Water Automation Controller. 

We already worked on water automation project, you can check out them

Modular Water Automation System

Component Requirement for Modular Water Automation System

Component Requirement for Modular Water Automation System

Project Used Hardware

  • Modular Water Management Controller (Designed and Developed by us),
  • SSR-75DA,
  • 12V-2A SMPS,
  • IP65 190x140x70 Enclosure,
  • GX-16 4 Pin Connector,
  • Float Switches,
  • Direction Control Valves.

Project Used Software

  • Platform IO,
  • EagleCAD,
  • Fusion360

Project Hardware Software Selection

ATMega328P Controller - We had selected this controller among other controllers is wide range of community and support, availability of the IC (Going to be used by the developers and hobbyists at-least for the rest of their lives).

SSR-75DA - Relays don't work well in high power environment that too with motors, For reliable and continuous operation of the system for at least 10 years, PCB trace for high power requirements are bulky and produce RFI which affects the controller and needs more filter circuits, For Easy replacement (Plug and Play type).

Direction Control Valve - It is a closed loop control since the opening and closing of the valve are done by the controller. Ball float valves are open loop and produce mechanical errors and failures. In case of the float switch above the ball float, the pump continuously runs and the ball float will be in a closed condition which results in catastrophic failure of the pump and piping systems.

GX-16 Connector - Misconnection of wire failures is also catastrophic and causes major failure. We don't give space to that also. Just plug and play. The polarity is not a pain anymore.

Water Automation Circuit Diagram

 

Water Automation System using ATMega328 Circuit Diagram

Our Modular Water Automation System. Here, the single pump unit controls the water to 4 Individual Over Head Tanks.

Code
#include <avr/wdt.h>
#define on LOW
#define off HIGH
const int firstdown = 2;
const int firstup = 3;
const int seconddown = 4;
const int secondup = 5;
const int mytanksol = 8;
const int tenantsol = 9;
const int motoron = 10;
const int motoroff = 11;
int temp;
int temporary;
int i = 0;
void setup() {
pinMode(firstdown, INPUT_PULLUP);
pinMode(firstup, INPUT_PULLUP);
pinMode(seconddown, INPUT_PULLUP);
pinMode(secondup, INPUT_PULLUP);
pinMode(motoron, OUTPUT);
pinMode(motoroff, OUTPUT);
pinMode(mytanksol, OUTPUT);
pinMode(tenantsol, OUTPUT);
digitalWrite(motoron, off);
delay(2000);
digitalWrite(mytanksol, off);
delay(500);
digitalWrite(tenantsol, off);
delay(500);
digitalWrite(motoroff, off);
wdt_enable(WDTO_4S);}
void loop() {
  i = 1;
  temp = digitalRead(firstdown);
  temporary = digitalRead(seconddown);
  if ((temp == off) && (temporary == off)){
    i = 0;
    normaltankfill();}
  else if (temp == off){
    i = 0;
    mytankautofill();}
  else if (temporary == off){
    i = 0;
    tenanttankautofill();}
  else if (i == 0){
      safetyprog();
      i += 1;}
  wdt_reset();}
void mytankautofill(){
  i = 0;
  while (digitalRead(firstup) == off){
    if (digitalRead(firstdown) == off){
      digitalWrite(mytanksol, on);
      delay(1000);
      if (i == 0){
      digitalWrite(motoron, on);
      delay(1000);
      digitalWrite(motoron, off);
      delay(1000);}
      i = 1;
      wdt_reset();}
    if (digitalRead(seconddown) == off){
      normaltankfill();}
    if (digitalRead(firstup) == on){
      delay(3000);
      wdt_reset();
      if (digitalRead(firstup) == on){
        digitalWrite(motoroff, on);
        delay(1000);
        digitalWrite(motoroff, off);
        delay(1000);
        digitalWrite(mytanksol, off);
        delay(1000);
        wdt_reset();}}}
        safetyprog();}
void tenanttankautofill(){
  i = 0;
  while (digitalRead(secondup) == off){
    if (digitalRead(seconddown) == off){
      digitalWrite(tenantsol, on);
      delay(1000);
      if (i == 0){
      digitalWrite(motoron, on);
      delay(1000);
      digitalWrite(motoron, off);
      delay(1000);
      wdt_reset();}
      i = 1;
      wdt_reset();}
    if (digitalRead(firstdown) == off){
      normaltankfill();}
    if (digitalRead(secondup) == on){
      delay(3000);
      wdt_reset();
      if (digitalRead(secondup) == on){
        digitalWrite(motoroff, on);
        delay(1000);
        digitalWrite(motoroff, off);
        delay(1000);
        digitalWrite(tenantsol, off);
        delay(1000);
        wdt_reset();}}}
        safetyprog();}
        void normaltankfill(){
i = 0;
  while ((digitalRead(firstup) == off) || (digitalRead(secondup) == off)){
      digitalWrite(mytanksol, on);
      delay(1000);
      digitalWrite(tenantsol, on);
      delay(1000);
      wdt_reset();
      if (i == 0){
      digitalWrite(motoron, on);
      delay(1000);
      digitalWrite(motoron, off);
      delay(1000);
      i = 1;
      wdt_reset();}
    if (digitalRead(firstup) == on){
      delay(3000);
      wdt_reset();
      if (digitalRead(firstup) == on){
        digitalWrite(mytanksol, off);
        delay(1000);
        wdt_reset();
        tenanttankcontrol();}}
    if (digitalRead(secondup) == on){
      delay(3000);
      wdt_reset();
      if (digitalRead(secondup) == on){
        digitalWrite(tenantsol, off);
        delay(1000);
        wdt_reset();
        mytankcontrol();}}}}
void mytankcontrol(){
  do{
    if (digitalRead(firstup) == on){
      digitalWrite(motoroff, on);
      delay(1000);
      digitalWrite(motoroff, off);
      delay(1000);
      digitalWrite(mytanksol, off);
      delay(1000);
      wdt_reset();
      safetyprog();}
      wdt_reset();}while (digitalRead(firstup) == off);}
void tenanttankcontrol(){
  do{
    if (digitalRead(secondup) == on){
      digitalWrite(motoroff, on);
      delay(1000);
      digitalWrite(motoroff, off);
      delay(1000);
      digitalWrite(tenantsol, off);
      delay(1000);
      wdt_reset();
      safetyprog();}
      wdt_reset();}while (digitalRead(secondup) == off);}
void safetyprog(){
digitalWrite(motoroff, on);
delay(1000);
digitalWrite(motoroff, off);
delay(1000);
digitalWrite(motoron, off);
delay(1000);
wdt_reset();
digitalWrite(mytanksol, off);
delay(1000);
digitalWrite(tenantsol, off);
wdt_reset();
loop();}
Have any question realated to this Article?

Ask Our Community Members