Inst ToolsInst ToolsInst Tools
  • Courses
  • Automation
    • PLC
    • Control System
    • Safety System
    • Communication
    • Fire & Gas System
  • Instrumentation
    • Design
    • Pressure
    • Temperature
    • Flow
    • Level
    • Vibration
    • Analyzer
    • Control Valve
    • Switch
    • Calibration
    • Erection & Commissioning
  • Interview
    • Instrumentation
    • Electrical
    • Electronics
    • Practical
  • Q&A
    • Instrumentation
    • Control System
    • Electrical
    • Electronics
    • Analog Electronics
    • Digital Electronics
    • Power Electronics
    • Microprocessor
  • Request
Search
  • Books
  • Software
  • Projects
  • Process
  • Tools
  • Basics
  • Formula
  • Power Plant
  • Root Cause Analysis
  • Electrical Basics
  • Animation
  • Standards
  • 4-20 mA Course
  • Siemens PLC Course
Reading: Level Measurement and Control using Arduino C
Share
Notification Show More
Font ResizerAa
Inst ToolsInst Tools
Font ResizerAa
  • Courses
  • Design
  • PLC
  • Interview
  • Control System
Search
  • Courses
  • Automation
    • PLC
    • Control System
    • Safety System
    • Communication
    • Fire & Gas System
  • Instrumentation
    • Design
    • Pressure
    • Temperature
    • Flow
    • Level
    • Vibration
    • Analyzer
    • Control Valve
    • Switch
    • Calibration
    • Erection & Commissioning
  • Interview
    • Instrumentation
    • Electrical
    • Electronics
    • Practical
  • Q&A
    • Instrumentation
    • Control System
    • Electrical
    • Electronics
    • Analog Electronics
    • Digital Electronics
    • Power Electronics
    • Microprocessor
  • Request
Follow US
All rights reserved. Reproduction in whole or in part without written permission is prohibited.
Inst Tools > Blog > Common > Level Measurement and Control using Arduino C

Level Measurement and Control using Arduino C

In this article, we will study liquid level measurement in the overhead tank using an Arduino microcontroller using C programming.

Last updated: September 20, 2022 4:39 pm
Editorial Staff
Common
No Comments
Share
9 Min Read
SHARE

In this article, we will study liquid level measurement in the overhead tank using an Arduino microcontroller.

Level Measurement and Control using Arduino C

 To avoid overflow of the tank the level must be measured and corrective action must be taken. Most people use an overhead tank called syntax to store water and the pump arrangement is used to lift the water from the source and use them, but when the tank gets full the water gets exited through an overflow pipe leads to loss of water.

To overcome the losses due to overflow, we have designed a system to measure the level of the tank using an Arduino microcontroller.

Circuit diagram of Liquid level measurment using Adruino C

What are the components required to measure the level of the liquid?

The required components are

Power Supply

The power supply required for this system is 12 V DC.

Ultrasonic Trans-receiver

  • The ultrasonic Trans-receiver HC-SR04 is used to transmit an ultrasonic wave. 
  • This is used because the human ear can hear the sound frequency around 20Hz to 40 kHz.
  • The ultrasonic sensor has 4 pins namely VCC, TRIGGER, ECHO, AND GROUND respectively.
  • The ultrasonic transmitter transmits the signal in the air in one direction and the start timing is launched. 
  •  And the signal returns immediately when an obstacle is encountered in the path.
  • The velocity of the ultrasonic wave is 340m/s.
  • The system works on the phenomenon of ECHO of sound.
  • The pulse is sent for about 10 microseconds to trigger the module.
  • The signal after striking or hitting the obstacle is captured by the receiver.
  • The distance from the obstacle to the sensor is calculated using the formula D= (T*S)/2.  
  • The pin details of HC-SR02
  • Pin No 1     VCC 5V             Supply
  • Pin No 2     TRIGGER          Pulse Input
  • Pin No 3     ECHO                Pulse Output
  • Pin No 4     GND 0V             Ground

Arduino Uno R3 microcontroller

  • The Microcontroller is a small computer on a single IC that includes Processor, memory, and Input and Output Peripherals.
  • The Arduino Uno is a Microcontroller board based on the ATmega328.
  • It has 14 digital input/output pins (of which 6 can be used as PWM outputs), and 6 analog inputs.
  • It is a 16 MHz crystal oscillator with a USB interface connection and a power jack, an ICSP header, and a reset button.
  • It can easily be connected to the computer via USB Port.
  • It can be easily powered through a power Jack using a 5V AC-to-DC adapter or battery.
  • Arduino Uno has its Integral Development Environment (IDE) that uses C-programming language.
  • Some of the Technical Specifications of Arduino Uno are listed below
  • Input Voltage (recommended) 7-12V
  • DC Current per I/O Pin 40 mA
  • DC Current for 3.3V Pin 50 mA
  • Flash Memory 32 KB of which 0.5 KB is used by the boot loader
  • SRAM 2 KB
  • EEPROM 1 KB
  • Clock Speed 16 MHz

Liquid Crystal Display

  • The Display unit RG1602A consists of 16 pins:
  • PIN 1 is the VSS or Ground pin.
  • PIN 2 is the VDD that provides a 5-volt DC supply to the Arduino Board.
  • PIN 3 is V0 which controls the brightness of the display through a variable potentiometer.
  • PIN 4 is the RS pin that selects Command / Data to the LCD.  If RS is low, the command is sent, if RS is High Data is sent to LCD.
  • PIN 5 is the R / W pin which selects the mode for LCD
  • PIN 6 is the E pin that enables the writing to the registers or the next 8 data pins
  • Pin 7 – Pin 14 D0 to D7 These Pins send 8-bit data to the Registers.
  • Pin 15 is Anode (A) and
  • Pin 16 (A) and Cathode (K) are for the LED backlight.

Pin Details of Display unit RG1602A.

How does the measurement system work?

The system working is as follows

  • The ultrasonic trans-receiver HC-SR04 transmits an ultrasonic signal of frequency 40 kHz through TRIGGER pin the Transmitter for the surface to be detected.
  • The signal will bounce after hitting the surface reflects back with a delay of 10 ms, and is received through the ECHO pin the receiver of HCSR04 respectively.
  • As a response, it will send an 8-cycle sonic pulse that travels at a speed of sound and is received in the ECHO pin.
  • The signal received from the ECHO pin is 2X times the transmitted signal from the TRIGGER pin.
  • The ultrasonic trans-receiver HC-SR04 measures the distance up to the range of 2 cm to 150 cm with an accuracy of 3mm.
  • The signal is traveled through the air medium with a speed of 340 m/s. If there is an obstacle found in its path it will reflect considering the travel time and speed of the sound.
  • Let us consider an object which is at a distance N from the sensor then the speed is 340m/s.
  • The time requires to calculate the duration of wave travel is given by

                              Time = Distance /Speed

  • The distance can be calculated using the relation

 Distance = (Time * Speed)/2.

                = (Time * 0.0342)/2.

What programming language is required to compose the program?

Usually, this program is written in the Arduino C program which is similar to a C program.

LIST OF PROGRAMS

Program 1 “Testing of Ultrasonic Trans-Receiver HC-SR04”

#define echoPin 7 // Echo Pin

#define trigPin 8 // Trigger Pin

#define LEDPin 13 // Onboard LED

int maximumRange = 200; // Maximum range needed

int minimumRange = 0; // Minimum range needed

long int duration, distance; // Duration used to calculate distance

void setup()

{

Serial.begin (9600);

pinMode(trigPin, OUTPUT);

pinMode(echoPin, INPUT);

pinMode(LEDPin, OUTPUT); // Use LED indicator (if required)

}

void loop()

{

digitalWrite(trigPin, LOW);

delayMicroseconds(2);

digitalWrite(trigPin, HIGH);

delayMicroseconds(2);

digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH);

distance = duration / 58.2;

if (distance >= maximumRange)

{

Serial.println(“out of area”);

digitalWrite(LEDPin, HIGH);

}

else if (distance <= minimumRange)

{

Serial.println(“within limit”);

digitalWrite(LEDPin, LOW);

}  }

Program to measure and indicate the status level

#include <LiquidCrystal.h>

#define trigger 7

#define echo 8

int Range1=0;

int Range2 = 4;

int Range3 = 8;

int Range4 = 12;

int Range5 = 16;

int Range6= 20;

LiquidCrystal.h lcd(12,11,5,4,3,2);

float time=0,level=0,distance=0;

void setup()

{

lcd.begin(16,2);

pinMode(trigger,OUTPUT);

pinMode(echo,INPUT);

lcd.setCursor(0,1);

lcd.clear();

}

void loop()

{

lcd.clear();

digitalWrite(trigger,LOW);

delayMicroseconds(2);

digitalWrite(trigger,HIGH);

delayMicroseconds(10);

digitalWrite(trigger,LOW);

delayMicroseconds(2);

time=pulseIn(echo,HIGH);

distance=time*340/20000;

lcd.clear();

lcd.print(“LEVEL:”);

lcd.print(distance);

lcd.print(“cm”);

lcd.setCursor(0,1);

if (distance <= Range1)

{

lcd.print(“OVERFLOW“);

}

else if (distance <= Range2)

{

lcd.print(“LEVEL VERY HIGH”);

}

else if (distance >= Range3)

{

lcd.print(“LEVEL HIGH “);

}

else if (distance >= Range4)

{

lcd.print(“LEVEL NORMAL”);

}

else if (distance >= Range5)

{

lcd.print(“LEVEL LOW”);

}

else if (distance >= Range6)

{

lcd.print(“LEVEL VERY LOW  PUMP ON “);

}

delay(1000);

}

Don't Miss Our Updates
Be the first to get exclusive content straight to your email.
We promise not to spam you. You can unsubscribe at any time.
Invalid email address
You've successfully subscribed !

Continue Reading

What is Hydraulic? Maintenance of Hydraulic Systems
Understanding the Chiller Maintenance – HVAC Tutorials
Types of Tachometers – Mechanical and Electrical Tachometers
Instrumentation Functional diagrams
Comparison of Humidity Sensors – Industrial Instruments
What is Eddy Current and Eddy Current Loss?
Share This Article
Facebook Whatsapp Whatsapp LinkedIn Copy Link
Share
Leave a Comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Stay Connected

128.3kFollowersLike
69.1kFollowersFollow
210kSubscribersSubscribe
38kFollowersFollow

Categories

Explore More

Difference Between Microcontroller and Microprocessor
What is Shielded Twisted Pair Cable? – Advantages, Disadvantages
Best Engineering Mobile Apps on Google Play & App Store
What is a Voltage Reference? – Electronic Components
HVAC Water Chillers Principle
Everything You Need to Know About Stainless Steel CNC Machined Parts
Career Scope in Mechanical Engineering
An Overview of Metrology Tools for CNC Machining

Keep Learning

Liquefied Petroleum Gas (LPG)

Properties of Liquefied Petroleum Gas (LPG)

Why does SMPS Need isolation - Switch Mode Power Supply

Why does SMPS Need isolation? – Switch Mode Power Supply

Industrial IoT Job Roles and Responsibilities

IoT Engineer Job Roles and Responsibilities

Hard-Wired Control Logic for the Pressure Alarm

Hard-Wired Control Logic for the Pressure Alarm

Bracelet Scanner

How to Use Bracelet Scanner? – Ultrasonic Thickness Gauge

Instrumentation in Industries

Why is Instrumentation used in Industries?

Reproducibility in Measurement

What is Reproducibility?

What is Linear Electric Motor

What is Linear Electric Motor?

Learn More

Digital Electronics Multiple Choice Questions

Register-Transistor Logic (RTL) Objective Questions

Vortex flow meter Bluff Body

Types of Vortex Flow Meter Sensors

Sensors and Transducers Objective Questions

Top 1000 Instrumentation Engineering Objective Questions

Rate of Rise Thermal Detectors Working Principle

Rate of Rise Thermal Detectors Working Principle

Linear Motion Control

What is Linear Motion Control? – Factors and Example Devices

Automatic Packing of Bottles

Automatic Packing of Bottles Programming

Electromagnetic

Types of Signals Based on Electromagnetic Compatibility (EMC Performance)

Drum Level differential pressure transmitter

Calculate Differential Pressure Sensed by Level Transmitter

Menu

  • About
  • Privacy Policy
  • Copyright

Quick Links

  • Learn PLC
  • Helping Hand
  • Part Time Job

YouTube Subscribe

Follow US
All rights reserved. Reproduction in whole or in part without written permission is prohibited.
Welcome Back!

Sign in to your account

Username or Email Address
Password

Lost your password?