Inst ToolsInst ToolsInst Tools
  • Courses
  • Videos
  • Q & A
    • Interview
      • Instrumentation
      • Electronics
      • Electrical
      • Practical Questions
    • MCQ
      • Instrumentation MCQ
      • Electrical MCQ
      • Electronics MCQ
      • Control Systems MCQ
      • Analog Electronics MCQ
      • Digital Electronics MCQ
      • Power Electronics MCQ
      • Microprocessor MCQ
      • Multiple Choice Questions
  • EE
    • Electronics
      • Electronics Q & A
      • Electronic Basics
      • Electronic Devices & Circuits
      • Electronics Animation
      • Digital Electronics
    • Electrical
      • Electrical Basics
      • Electrical Q & A
      • Power Electronics
      • Electrical Machines
      • Electrical Animation
      • Power Systems
      • Switchgear & Protection
      • Transmission & Distribution
  • Measure
    • Control Valves
    • Calibration
    • Temperature
    • Pressure
    • Flow
    • Level
    • Analyzers
    • Switches
    • Vibration
    • Solenoid Valve
  • Control
    • PLC Tutorials
    • Control Systems
    • Safety Instrumented System (SIS)
    • Communication
    • Fire & Gas System
  • More
    • Design
    • Tools
    • Animation
    • Basics
    • Formulas
    • Standards
    • TextBooks
    • Common
    • Software
    • Excel Tools
    • Erection & Commissioning
    • Process Fundamentals
    • Videos
    • Books
Search
All rights reserved. Reproduction in whole or in part without written permission is prohibited.
Reading: Level Measurement and Control using Arduino C
Share
Notification Show More
Font ResizerAa
Inst ToolsInst Tools
Font ResizerAa
  • Courses
  • PLC Tutorials
  • Control Systems
Search
  • Courses
  • Videos
  • Q & A
    • Interview
    • MCQ
  • EE
    • Electronics
    • Electrical
  • Measure
    • Control Valves
    • Calibration
    • Temperature
    • Pressure
    • Flow
    • Level
    • Analyzers
    • Switches
    • Vibration
    • Solenoid Valve
  • Control
    • PLC Tutorials
    • Control Systems
    • Safety Instrumented System (SIS)
    • Communication
    • Fire & Gas System
  • More
    • Design
    • Tools
    • Animation
    • Basics
    • Formulas
    • Standards
    • TextBooks
    • Common
    • Software
    • Excel Tools
    • Erection & Commissioning
    • Process Fundamentals
    • Videos
    • Books
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.

Contents
Level Measurement and Control using Arduino CPower SupplyUltrasonic Trans-receiverArduino Uno R3 microcontrollerLiquid Crystal Display

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 !

Recommended Articles

What is a Laser Sensor? Principle
Top 100 Microcontrollers Project Ideas
Car Lifts – Choosing the Right One for Your Mechanic Shop
What is an IP address? How to Set IP Address of the Computer?
Job and Career Opportunities in Instrumentation Engineering
Supermarket Ventilation System – HVAC Basics
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
208kSubscribersSubscribe
38kFollowersFollow

Categories

Recent Comments

  • William Snyder on Top Non-PLC Certification Courses for Automation Professionals
  • Kamli on Top Free PLC Software
  • Guifty Shimica on Top Non-PLC Certification Courses for Automation Professionals
  • Guifty Shimica on Top Non-PLC Certification Courses for Automation Professionals

Related Articles

Chemical Reactor Vessel P and ID

Questions on Chemical Reactor Vessel P & ID

Best Engineering Mobile Apps

Best Engineering Mobile Apps on Google Play & App Store

Password Protect Apps and Files

5 Best Mobile Apps to Password Protect Applications and Files

PCB Assembly

Five Types of PCB Assembly that You Should Know

The Top Services a Great B2B Agency Offers

The Top Services a Great B2B Agency Offers

different types of threads based on 4 standards

Different Types of Threads based on 4 Standards

Magnetic Tape Recorder Principle

What is Magnetic Tape Recorder ?

Compressor Shutdown Jobs

Compressor Shutdown Job – Instrumentation Engineer Duties

More Articles

Faceplate in WinCC

Siemens HMI Training – Using UDTs with Faceplates

Thermoelectricity principle

Methods of Producing Voltage (Electricity)

Top Most Popular CNC Software Programs

Top Most Popular CNC Software Programs – A Comprehensive List

Pressure Unit Conversion Practical Example

Pressure Unit Conversion Practical Example

Electrical and Instrumentation Maintenance Test

Electrical and Instrumentation Test

Pressure Transmitters Purged impulse lines - 2

Pressure Transmitters Purged impulse lines

Servo Operated Float Level Measurement

Servo Operated Float Level Measurement

Crowbar fault protection circuit

Crowbar fault protection circuit

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?