Arduino Based Water Tank - Level & Flow rate [Auto Cutoff ]


This Project idea explains how to automatically control water pump operation according to the tank water level and flow rate.

An ultrasonic sensor detects the water level and start the pump if the water level is below 25%.

The flow rate cannot be determined initially, because initially there is no water flow through the water flow sensor.

Hence the 30% level limit has been set.

If the water level is above 30% and the water flow rate is below 0.5Liter/min , then the relay remains in NO(Normally Open) position and the power supply to the pump motor stays cutoff.

If the water level is above 30% and the water flow rate is above 0.5Liter/min , then the relay operates and the power will be supplied to pump motor.(To protect the pump motor)

If the water level reaches 95% , then the relay will disconnect power to the pump motor,hence there will be no water overflow.

Water level(always) and the Flow rate(only when water flows through the sensor) is displayed on the LCD Screen.Hence the user can monitor the water level and flow rate.

Note : Before building this project please be aware of the components used and their capabilities.

Tools & Components

1 X Arduino Nano

1 X 5V/230V 1Hp Relay

1 X Ultrasonic Sensor(HC-SR04)

1 X Water Flow Rate Sensor (YF S201)

1 X 16x2 LCD Module

1 X  10K Ohm Potentiometer

1 X 0.5HP Water Pump

1 X 500 Liters Water Tank

1/2" PVC Pipes (for water flow rate sensor,tank and water pump)

PVC Fittings,Valves & piping glue

The control system is the main concern of this project.Hence you can arrange suitable plumbing equipment accordingly.

Connecting Components


Water Level Sensor Signal Pin - Arduino Pin D12

Relay Signal Pin                        - Arduino Pin D13

Ultrasonic Trig. Pin                   - Arduino Pin D03

Ultrasonic Echo Pin                   - Arduino Pin D02

LCD  RS Pin                              - Arduino Pin A02

LCD  EN Pin                              - Arduino Pin A03

LCD  D4 Pin                              - Arduino Pin A04

LCD  D5 Pin                              - Arduino Pin A05

LCD  D6 Pin                              - Arduino Pin A06

LCD  D7 Pin                              - Arduino Pin A07

Arduino Code

//2020 CraftyBin.blogspot.com
//Author : Chathura H.

#include <LiquidCrystal.h>
#include <HCSR04.h>
UltraSonicDistanceSensor distanceSensor(3, 2);
int LCD;

const int rs = A2, en = A3, d4 = A4, d5 = A5, d6 = A6, d7 = A7;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
byte Relay    = 13;

byte sensorInterrupt = 0; 
byte sensorPin       = 12;


float calibrationFactor = 7.5;

volatile byte pulseCount; 

float flowRate;
unsigned int flowMilliLitres;
unsigned long totalMilliLitres;

unsigned long oldTime;

void setup()
{
 
  pinMode(Relay, OUTPUT);
  pinMode(sensorPin, INPUT);
  digitalWrite(sensorPin, HIGH);

  pulseCount        = 0;
  flowRate          = 0.0;
  flowMilliLitres   = 0;
  totalMilliLitres  = 0;
  oldTime           = 0;

  attachInterrupt(sensorInterrupt, pulseCounter, FALLING);
}


void loop()

   LCD = map( distanceSensor.measureDistanceCm(), 0, 95, 100, 0);
   delay(1);

   lcd.begin(16, 2);
   lcd.print("LEVEL : ");
   lcd.print(LCD);   
   lcd.print("%");
   delay(500);
   lcd.clear();
   delay(1);
  
   if((millis() - oldTime) > 1000)   
  {
   
    detachInterrupt(sensorInterrupt); 
    flowRate = ((1000.0 / (millis() - oldTime)) * pulseCount) / calibrationFactor;
    oldTime = millis();
    flowMilliLitres = (flowRate / 60) * 1000;
    totalMilliLitres += flowMilliLitres;
     
    unsigned int frac;

  lcd.print("Flow Rate: ");
  lcd.print(flowRate);     
  lcd.print("L/Min");
  delay(500);
  lcd.clear();
  delay(1);
 
  pulseCount = 0;
  attachInterrupt(sensorInterrupt, pulseCounter, FALLING);
  }

  if ( LCD <= 25){
    digitalWrite(Relay,HIGH);
  }

  else if(LCD >= 95){
    digitalWrite(Relay,LOW);
  }

  else if(flowRate <= 0.500 && LCD >=30){
    digitalWrite(Relay,LOW);
  }

  else if(flowRate >= 0.500 && LCD >=30){
    digitalWrite(Relay,HIGH);
  }

  else if(flowRate <= 0.500 && LCD >=95){
  digitalWrite(Relay,LOW);
  }
}
 
void pulseCounter()
{
  pulseCount++;
}


//Change the code according to tank depth & required minimum flow rate.

Safety First !
Always Connect the main power supply if you are absolutely sure that the components are connected correctly without changing polarity and short circuited the wiring.
Even if it seems nothing is wrong : DOUBLE CHECK EVERYTHING !!
Your Feedback is very important to us. 
Please Leave a comment about how you feel about this project.


 










2 Comments

  1. It is truly a well-researched content and excellent wording. I got so engaged in this material that I couldn’t wait to read. I am impressed with your work and skill. Thanks. Read more info about Furnace Cleaning Edmonton

    ReplyDelete

Post a Comment

Previous Post Next Post