You are on page 1of 53

1

FINAL REPORT

COURSE: WATER SUPPLY AND SEWERAGE

QUALIFICATION: ELEVATED TANK OPTIMIZATION

STUDENT1: MORALES FLORES MANUEL ALEJANDRO


STUDENT2: BARNETT MARTINEZ LUIS ALEJANDRO
STUDENT3: CUTIPA RAMOS JEMY ALEXANDER
STUDENT4: RIVEROS ROMERO ELER
STUDENT5: BECERRA MIRANDA JESUS SIMON

SECTION:09N03

TEACHER: ING. FERNANDO PAZ ZAGACETA

ACADEMIC SEMESTER: 2023-II

LIME–PERU
2

index
I. Introduction ........................................................................................................................... 4
II. Goals ...................................................................................................................................... 5
2.1. General objective ........................................................................................................... 5
2.2. Specific objectives .......................................................................................................... 5
III. Theoretical framework ...................................................................................................... 5
3.1. Programming, sensors and Arduino. ............................................................................. 5
3.1.1. Programming.......................................................................................................... 5
3.1.2. Arduino................................................................................................................... 6
3.1.3. pH sensor ............................................................................................................... 7
3.2. Control and optimization ............................................................................................. 11
3.2.1. pH control: ........................................................................................................... 11
3.2.2. Flow Optimization: ............................................................................................... 11
3.3. Communication Technologies:..................................................................................... 11
3.3.1. Wireless communication: .................................................................................... 11
3.4. Security and Redundancy: ........................................................................................... 12
3.4.1. Emergency Response Systems: ............................................................................ 12
3.5. Data Integration and Visualization Platforms .............................................................. 12
3.5.1. SCADA Systems (Supervision, Control and Data Acquisition): ............................. 12
IV. Development of experience............................................................................................. 12
4.1. Equipment and materials ............................................................................................. 12
4.1.1. Sensors and Actuators ......................................................................................... 13
4.1.2. Tools: .................................................................................................................... 20
4.2. Procedure ..................................................................................................................... 23
4.2.1. Initial setup: ......................................................................................................... 23
4.2.2. pH Measurement and Analysis: ........................................................................... 23
4.2.3. Level Measurement ............................................................................................. 23
4.2.4. Flow Measurement .............................................................................................. 23
4.2.5. pH Evaluation and Flow Control .......................................................................... 24
4.3. Results .......................................................................................................................... 24
3

4.4. pH: ................................................................................................................................ 24


4.5. Tank Level: ................................................................................................................... 24
4.6. Flow: ............................................................................................................................. 24
4.7. pH rating: ..................................................................................................................... 25
V. Discussions ........................................................................................................................... 25
5.1. Student: MORALES FLORES, MANUEL ALEJANDRO ..................................................... 25
5.2. Student: BARNETT MARTINEZ, LUIS ALEJANDRO ........................................................ 25
5.3. Student: CUTIPA RAMOS JEMY ALEXANDER ................................................................ 26
5.4. Student: RIVEROS ROMERO ELER ................................................................................ 27
5.5. Student: Becerra miranda Jesús Simón ....................................................................... 28
VI. Conclusions ...................................................................................................................... 28
VII. recommendations ............................................................................................................ 29
VIII. Bibliography: .................................................................................................................... 30
IX. Exhibit .............................................................................................................................. 31
9.1. Work photography ....................................................................................................... 31
9.2. Arduino code ................................................................................................................ 40
4

I. Introduction

The purpose of this project is to present the automatic supervision system,

elevated tank level control, acidity level control (PH) to guarantee the supply and

quality of water; in a family home, in an educational center or in any project where

such sensors are required and installed that provide us with exact data carried

hand in hand with programming that provides us with the data accurately. which

will consist of an automatic system that is composed of three sensors among

them: level sensor or also called ultrasonic distance sensor is a device that uses

ultrasonic waves to measure the distance between the sensor and an object,

acidity level sensor or Also called a PH sensor, it is a device used to measure the

level of acidity or alkalinity of a solution and finally, a flowmeter sensor is a device

used to measure the flow rate of a fluid, whether liquid or gas, through a conduit

or pipe. Currently in our country, specifically on our Peruvian coast, we are

suffering from a shortage of water that is so fundamental for life.According to

Sunass (national sanitation service superintendency), we would not suffer a large

magnitude of water shortages this year because Sedapal has sufficient reserves

to cover the aquifer demand of 2023. However, climatic factors could affect the

distribution of this resource in Lima during 2024 reaching peak points of scarcity

not experienced before.damaging health conditions such as cleanliness of

hygienic services and personal hygiene, putting people's health at risk, which is

why the importance of the project to be developed, which consists of an automatic

system for monitoring and controlling water level and acidity level .
5

II. Goals

2.1. General objective

Design a system for monitoring and controlling the elevated tank level to

guarantee the water supply in a family home.

2.2. Specific objectives

- Know the level of consumption of a family home.

- Know tank level supervision and control techniques

- Plan the ARDUINO system to be used

- Design the link between control center and Tank

- Select equipment and instruments for supervision and control

- Simulate the system

III. Theoretical framework

3.1. Programming, sensors and Arduino.

3.1.1. Programming

Programming is the process of writing and developing instructions or

algorithms that allow a computer to perform specific tasks. Programming

languages are used to communicate with the computer and give it instructions on

what to do. Some popular programming languages include Python, Java, C++,

JavaScript, among others.


6

Programming is used in a wide range of applications, from developing

software and mobile applications to creating websites and controlling electronic

devices. It allows programmers to create custom solutions and automate tasks to

improve efficiency and productivity.

3.1.2. Arduino

Arduino is an open source development platform that combines a hardware

board with a reprogrammable microcontroller and a series of connection pins. It

allows the programming and control of electronic devices in a simple and flexible

way.
7

3.1.3. pH sensor

A pH sensor is a device used to measure the level of acidity or alkalinity of

a solution. These sensors are widely used in applications such as the chemical

industry, agriculture, scientific research and water monitoring.

pH sensors generally consist of a pH-sensitive glass electrode and a

reference electrode. The glass electrode generates an electrical signal

proportional to the pH level of the solution, while the reference electrode provides

a stable reference for measurement.

Some important features and considerations about pH sensors are:

• Measuring range: pH sensors can measure the pH level in a specific

range, usually between 0 and 14. Some sensors are designed to measure only in

the acidic, alkaline or neutral range, while others can cover the entire range.

• Calibration: pH sensors should be calibrated regularly using

solutions of known pH to ensure accurate measurements. Calibration adjusts the

sensor response to compensate for any deviation or drift.


8

• Care and maintenance: pH sensors are sensitive and require proper

care. It is important to store them correctly, clean them regularly, and replace the

electrodes according to the manufacturer's recommendations.

• Interferences: Some substances or conditions can interfere with pH

measurements, such as the presence of metal ions, high concentrations of salts,

or extreme temperatures. In such cases, compensation or correction methods

may be necessary.

3.1.3.1. Flow sensor

A flow sensor or flowmeter is a device used to measure the flow rate of a

fluid, whether liquid or gas, through a conduit or pipe. Provides information about

the amount of fluid passing through a specific point in a given period of time.

There are different types of flowmeters, each with its own operating

principle. Some of the most common types are:


9

- Differential Pressure Flowmeter: Uses a restriction in the duct to create

a pressure drop. The pressure difference is measured and used to

determine the flow rate. Examples of differential pressure flowmeters

are orifice, flow plate, and Venturi tube.

- Electromagnetic flowmeter: Uses the principle of Faraday's law to

measure flow. A magnetic field is applied to the fluid and, as it passes

through the conduit, generates an electromotive force proportional to

the velocity of the fluid. This electromotive force is measured and used

to determine the flow rate.

- Ultrasonic flowmeter: Uses ultrasonic waves to measure flow.

Ultrasonic pulses are emitted through the fluid and the time they take

to travel in different directions is measured. The time difference is used

to calculate the flow rate.

- Positive displacement flowmeter: Uses a displacement mechanism to

measure flow. The fluid causes a rotor or piston to move, and the

momentum is used to determine the flow rate.

3.1.3.1.1. Ultrasonic or level sensor


10

An ultrasonic sensor is a device that uses ultrasonic waves to measure the

distance between the sensor and an object. These sensors emit high-frequency

pulses of sound and measure the time it takes to bounce off the object and return

to the sensor. The distance is calculated based on the flight time of the sound.

Ultrasonic sensors are widely used in various applications such as obstacle

detection, automatic parking systems, security systems, mobile robots, navigation

systems and more. Some of the advantages of ultrasonic sensors include:

- Non-contact: Ultrasonic sensors can measure distances without

requiring physical contact with the object, making them ideal for

applications where interference-free measurement is required.

- Reasonable accuracy: Ultrasonic sensors can provide accurate

measurements over short and medium distances, usually within a few

millimeters.
11

- Easy to use: Ultrasonic sensors are relatively easy to implement and

use. Most of them can be easily connected to microcontrollers like

Arduino and programmed to perform various tasks.

- Reasonable Cost: Ultrasonic sensors are generally affordable and

widely available in the market.

3.2. Control and optimization

3.2.1. pH control:

pH stability is crucial in chemical and biological processes. Control systems

automatically adjust the addition of chemicals to maintain the pH within desired

limits, avoiding sudden changes that could affect the quality of the stored liquid.

3.2.2. Flow Optimization:

Accurate flow measurement allows for efficient resource management.

Optimization algorithms can adjust valves to maintain a constant flow or adjust

pumping speed based on demand, contributing to energy efficiency and fluid

conservation.

3.2.2.1. Tank Level Management:

Tank level control involves regulating inlet and outlet flow to prevent

overflow or operation at critically low levels. Predictive algorithms can anticipate

changes in level based on historical patterns.

3.3. Communication Technologies:

3.3.1. Wireless communication:


12

The integration of wireless communication modules, such as Wi-Fi or

Bluetooth, facilitates the transmission of system data to a central platform. This

enables remote monitoring and decision making based on real-time data.

3.4. Security and Redundancy:

3.4.1. Emergency Response Systems:

Implementing automatic response systems for critical events, such as

overflows or extreme changes in pH, improves system safety. This could include

activating alarms, stopping pumps or automatically opening and closing valves.

3.4.1.1. Redundant Systems:

The incorporation of redundancies in instrumentation and control systems

guarantees the reliability of monitoring. This involves duplicating critical sensors

and implementing backup systems to avoid catastrophic failures.

3.5. Data Integration and Visualization Platforms

3.5.1. SCADA Systems (Supervision, Control and Data Acquisition):

The integration of a SCADA system allows for centralized monitoring,

control and data collection. These platforms offer intuitive visual interfaces and

analytical tools to evaluate system performance over time.

IV. Development of experience

4.1. Equipment and materials


13

To carry out the "Elevated Tank Optimization" project, the following

equipment and materials were used:

4.1.1. Sensors and Actuators

4.1.1.1. pH sensor- PH0-14

A liquid pH sensor with a measurement range of 0-14 is used to measure

the level of acidity or alkalinity in aqueous solutions. This device uses a

specialized electrode that reacts with hydrogen ions, generating an electrical

signal proportional to pH. It is crucial to regularly calibrate the sensor with known

buffer solutions to maintain accuracy. It can be connected to development boards

such as Arduino, and is commonly used in laboratories, aquaculture, water quality

control, and irrigation systems. Care and maintenance, as well as attention to the

limitations of the sensor, are essential to obtain reliable measurements.

4.1.1.2. Ultrasonic sensor for level measurement.


14

An ultrasonic sensor is a device that measures distances using ultrasonic

waves. It works by emitting sound pulses and calculating the distance based on

the time it takes for the echo to return. It is composed of a transducer to emit and

receive waves, a timer to measure time and a microcontroller to process the

information. It is conveniently used to measure distances, avoid obstacles in

robots and vehicles, and monitor levels in tanks. Its measurement range can vary

from centimeters to several meters, depending on the model. This type of sensor

is especially useful in environments that are not transparent to sound.

4.1.1.3. Flow sensor

A water flow sensor is a device designed to measure the rate of water flow

through a pipe or a specific section of a water system. It uses a Hall effect sensor

or turbine mechanism to interact with the water flow and generate an electrical

signal proportional to the flow rate. These sensors are used in water monitoring

systems, such as smart irrigation systems, industrial water processing, and home

water consumption monitoring. They can come in different shapes, such as in-

line sensors or push-in sensors for larger pipes. Accuracy may require periodic

calibration, and many sensors provide digital pulse output that correlates with flow
15

rate. Proper installation and consideration of water quality are important to obtain

accurate readings. These sensors can be integrated with microcontroller

platforms such as Arduino or Raspberry Pi todata logging and control

applications.

4.1.1.4. LCD (Liquid Crystal Display)

A liquid crystal display (LCD) is a visual device used in electronic devices

to display information. It works by manipulating liquid crystals between layers of

glass, controlling the orientation of these crystals to modulate light and generate

images. LCD screens can be LED backlit and there are different types, such as

active matrices (TFT) and passive matrices. They are known for their thinness,

low power consumption, and are used in a variety of devices, from smartphones

and tablets to monitors and televisions. Their basic structure includes individually

controlled pixels and can offer different viewing angles depending on the type of

technology used.
16

4.1.1.5. Standard Arduino Components

Standard components used with Arduino development boards include

resistors to limit current, jumper wires to connect pins, diodes to control the

direction of current, LEDs to indicate states, capacitors to filter noise and stabilize

voltages, transistors to control current . , buttons for user input, sensors to

measure the environment, screens to display information, buzzers or speakers to

emit sounds, potentiometers for adjustable inputs, motors to add motion, relays

to control higher power circuits, crystal oscillators to stabilize frequency clock, and

voltage regulators to maintain a stable power supply.


17

4.1.1.6. Components for the implementation of the elevated tank

- ½ elbow

-pass key
18

-½ tube

-Glue
19

-Teflon

-Mixed union of ½

-Adapter
20

-2.5 liter container with lid

4.1.2. Tools:

4.1.2.1. Arduino development board

The Arduino Nano is a compact and versatile development board within

the Arduino family. It stands out for its small size similar to that of a credit card.

Equipped with an ATmega microcontroller, it offers technical specifications such

as 32 KB of Flash memory, 2 KB of SRAM and 8 analog inputs, among others. It

has pins for various connections, including digital inputs/outputs, and is

programmed using the Arduino IDE environment. With USB interface, it is used

in projects where space is limited, such as embedded controllers, monitoring

systems and portable devices. Although smaller, the Arduino Nano is compatible

with many of the shields designed for larger Arduino boards, making it versatile

and popular in the maker community.


21

4.1.2.2. Breadboard for connecting components

The breadboard is a fundamental tool in electronics for rapid prototyping

and temporary connection of components without soldering. Its design features a

perforated surface with electrically connected holes, allowing the connection of

components using jumper cables. Features like numbered holes, power rails, and

adhesive on the base make it easy to organize and test circuits. This versatility

and flexibility make it ideal for prototyping Arduino projects and experimenting

with different circuit configurations. Although not suitable for permanent

applications due to wear and tear over time, the breadboard is essential in DIY

projects, electronics education, and laboratory prototyping.


22

4.1.2.3. Power supply

The Arduino power supply refers to the external power source used to

power the development board. Common options include connecting USB to a

computer, a USB power adapter, or using batteries. It is crucial to respect the

voltage and current specifications of the board to avoid damage. Some Arduino

boards have voltage regulators, and specialized sources such as solar panels or

UPS can be used for specific projects. The power supply is essential for a variety

of applications, from educational projects to embedded systems and IoT devices


23

4.2. Procedure

The procedure for optimizing the elevated tank was divided into the

following stages:

4.2.1. Initial setup:

-Connection of sensors and actuators to the Arduino development board.

-System initialization, displaying welcome messages on the LCD screen.

4.2.2. pH Measurement and Analysis:

-Take 20 samples from the pH sensor to perform a statistical analysis.

-Calculate the mean, median, standard deviation, and maximum and

minimum values of the pH readings.

-Automatically classify pH into categories (acidic, neutral, alkaline).

4.2.3. Level Measurement

-Use an ultrasonic sensor to measure the distance and ultimately the level

of the liquid in the tank.

-Calculate the volume of liquid in the tank using a predefined area.

4.2.4. Flow Measurement

-Use a flow switch to count the number of pulses, representing the flow of

liquid.
24

-Calculate the volume of liquid flowing through the system based on the

pulses.

4.2.5. pH Evaluation and Flow Control

-Classify pH and display results on LCD screen.

-Evaluate flow and display results on LCD screen.

4.3. Results

The results obtained from the measurements and analyzes are the

following:

4.4. pH:

pH medium: 3.2

Median pH: 5.2

Standard Deviation: 6.5

Minimum Value: 0.05

Maximum Value: 12

4.5. Tank Level:

Medium Level: 15 cm

Tank Volume: 2.5L

4.6. Flow:

Total liquid volume: 22.5 mL in 5 seconds


25

4.7. pH rating:

The pH of the liquid is classified as [acid/neutral/alkaline], with a value of 4

These results provide key information about the health of the system and

are critical to understanding and optimizing the elevated tank.

Remember to customize the numerical values with the actual data obtained

during your experiment.

V. Discussions

5.1. Student: MORALES FLORES, MANUEL ALEJANDRO

Tank optimization is addressed through structural design, implementation

of sensors to measure key parameters, and important considerations such as

regulatory compliance, durability, water efficiency, and sustainability. Additionally,

advanced aspects are explored, including the integration of emerging

technologies, cost analysis, energy efficiency, system scalability, personnel

training, and compliance with environmental standards. This discussion reflects a

deep understanding of the essential elements that a civil engineering student

might consider when approaching infrastructure projects.

5.2. Student: BARNETT MARTINEZ, LUIS ALEJANDRO

In the proposal to integrate sensors for monitoring the elevated tank, I see

a very promising approach to optimize our water resource management. The

inclusion of a pH sensor is particularly interesting, as it gives us detailed


26

information about the quality of the water. How do we plan to address potential

variations in pH and what impact could they have on supply?

The ultrasonic sensor for measuring tank volume is a wise choice. This

should help us avoid overflow or shortage issues by having a more accurate

understanding of storage levels. Are there any special considerations for the

calibration of this sensor regarding possible external interference?

The flow sensor also adds a valuable component to the system by

providing information on the speed and amount of water flowing. How do we plan

to use this data to adjust our distribution strategies? Have we considered possible

fluctuations in flow and how they might affect our planning?

Overall, I believe this comprehensive approach is an important step

towards more efficient and sustainable water management. However, it would be

useful to discuss further how we will address potential challenges and how we will

ensure the continued reliability and accuracy of the sensors. Are there backup

measures in case any of the sensors fail? Overall, I'm excited by the potential of

this project and look forward to continuing to discuss and improve these key

aspects.

5.3. Student: CUTIPA RAMOS JEMY ALEXANDER

In the project that was established where a prototype is used for the

simulation of an elevated tank, where we integrate flow rate sensors, flow

measurement, pH measurement, water level measurement, and in the work we

integrate all these sensors to see the maximum daily flow that a population could
27

have in a home and this will help us improve the quality of life of people and

control the amount of water in each home

Regarding the pH sensor, it is almost different from the flow system, in this

system we must, since we could see the quality of the water, which could be

between acidic and basic and is a complement to the water quality system.

For an initiative on my part, a real network system on a small scale could

be implemented with the prototype that we made, where we simulate the water

network in pipes to simulate the flow for a better study of the behavior of the fluid

in the meters installed in the properties and thus be able to determine a more real

study.

Finally, with the development of this research and the creation of this

prototype, the central axis is the measurement of water consumption in a home

and in the future projecting it to a small-scale distribution network and thanks to

this knowledge of the project carried out in Arduino it helped me to have a better

idea of the water and sewage system, as well as knowledge of sensors and a

physical-electrical technology system for the course.

5.4. Student: RIVEROS ROMERO ELER

After carrying out the project and seeing the results of the flow meter, we

realize that the daily demand constantly changes depending on the day and time.

Which helped us calculate the volume of water necessary for our elevated tank

and thus meet the required demand. The pH sensor gives us approximate values
28

between +/- 1 (pH), which is not very safe to rely on the sensor and its

programming since when doing a project it is necessary to know the real value of

the pH, and so make a good elevated tank design

5.5. Student: Becerra miranda Jesús Simón

The project uses an Arduino with sensors to measure pH, flow and liquid

level. Information is displayed on an LCD screen. The code includes functions to

calculate statistics such as mean and standard deviation of pH, as well as

measure liquid flow and level. The pH is also classified into acidic, neutral or

alkaline categories. The estimated time for liquid flow is also calculated and

displayed. It is suggested to improve the code structure, handle limits and errors,

and consider system integration and scalability.

VI. Conclusions

- It was possible to recognize that of a current family home, observing

the daily expenditure and thus being able to know and predict the water

supply for said home.

- Tank level supervision and control techniques were studied, which

helped us design the control and supervision system.

- The ARDUINO system to be used was designed and proposed, which

provided us with programming and control of electronic devices in a

simple and flexible way.


29

- The radio link between the control center and the elevated tank was

designed.

- It was possible to know the PH level in the elevated tank and in this way

be able to control it at a level that is not harmful to health.

VII. recommendations

- For future work in the supply and sewage course, a greater number of

sensors could be implemented, in order to collect more information

regarding water analysis.

- Include and carry out constant monitoring of the proposed design for

the water supply structure and measurement of flow, pH, to verify what

deficiencies could be present in its operation, and in this way ensure

that the aqueduct system satisfies the demand of the population to

implement.

- For the PH measurement, the average amount of solution considered

as a material must be estimated, and this must cover the sensor

completely, without excess. It is because, in this way, the sensor

reception can be optimal and thus provide much more precise

measurements.

- It is recommended to perform calibration and testing of all field

instruments (sensors, transmitters, indicators, etc.) that are

implemented, in order to maintain real and unaltered field data transfer;


30

that is, as part of the preventive maintenance that is carried out on the

reservoir, in order to avoid failures that affect the operation.

VIII. Bibliography:

• Farrier, R. E. (2009). Arduino User Guide


https://www.uco.es/aulasoftwarelibre/wp-
content/uploads/2010/05/Arduino_user_manual_es.pdf
• Goilav, N., & Geoffrey, LOI (2016). Arduino: Learn to develop to create smart objects.
ENI Editions.
https://books.google.es/books?hl=es&lr=&id=R6RCxQl_H6YC&oi=fnd&pg=PA9&dq=pr
ograma+arduino&ots=0cFez6to3-
&sig=7oPkl5XjSc7CZSOvfJuz5BHVpA8#v=onepage&q=programa%20arduino&f=false
• Peña, C. (2020). Arduino IDE: Master programming and control the board. RedUsers.
https://books.google.es/books?hl=es&lr=&id=Xgv2DwAAQBAJ&oi=fnd&pg=PP1&dq=pr
ograma+arduino&ots=vNG-K9Wx7U&sig=RPfYZmtDj8R61Dl-g-
Mx26khV5c#v=onepage&q=programa%20arduino&f=false
• Umaña, LAR (2016). Evaluation of the effects of flow variation on ammonium, nitrate
and pH levels of an aquaponic cultivation prototype. Ingenio Magno, 7, 126-138.
http://revistas.ustatunja.edu.co/index.php/ingeniomagno/article/view/1199
• Buenahora Vergel, A., Cárdenas Ardila, JC, & Iglesias Nieto, MA (2019). Prototype of
monitoring system for the status of the variables (ph, turbidity, flow, tank level and
electrical system) of the Guayabal de Síquima drinking water treatment plant.
https://repositorio.unbosque.edu.co/handle/20.500.12495/10260
• González Cuervo, HA, & Perdomo Marin, JC (2019). Development of a flexible
electronic prototype that allows controlling the PH level in water purification plants.
https://repositorio.uniajc.edu.co/handle/uniajc/1141
• Gaibor Nieto, JA, & Villavicencio Bajaña, WF (2020). Design of a monitoring system to
measure the flow and depth of channels for the hydraulics laboratory of the Faculty of
Mathematical and Physical Sciences of the University of Guayaquil
http://repositorio.ug.edu.ec/handle/redug/48858
• Corapi, P., Chacón, XCA, Nieto, JAG, & Bajaña, WFV (2021). Flow and depth monitoring
system for the Hydraulics Pilot Laboratory of the Faculty of Mathematical and Physical
Sciences. Research, Technology and Innovation, 13(14), 1-17.
http://repositorio.ug.edu.ec/handle/redug/48858
31

• Rivera, G., Perpiñan, G., Severeyn, E., Wong, S., & Altuve, M. DESIGN AND
DEVELOPMENT OF A PROTOTYPE OF A MOBILE MEDICAL MEASUREMENTS MODULE
USING ARDUINO.
https://www.academia.edu/download/47430656/cimenicsGR.pdf

IX. Exhibit

9.1. Work photography

EXHIBIT
PIPE ASSEMBLY AND FLOW MEASUREMENT SENSOR
32

ASSEMBLY OF THE PROTOBOARD WITH THE MEASUREMENT SYSTEM

TIME AND DISTANCE SYSTEM


33

TANK PROTOTYPE LEVEL SENSOR SYSTEM


34

ASSEMBLY OF THE PROTOBOARD WITH THE MEASUREMENT SYSTEM


35

ASSEMBLY OF THE PROTOBOARD WITH THE SYSTEM SCREEN

ASSEMBLY OF THE PROTOBOARD WITH THE MEASUREMENT SYSTEM


36

ASSEMBLY OF THE FLOW MEASUREMENT SYSTEM STOP KEY


37

SOLVENTS FOR FLOW MEASUREMENT

OPERATION OF THE PROJECT MEASUREMENT SYSTEM


38

OPERATION OF THE PROJECT MEASUREMENT SYSTEM


39

DESIGN OF THE MEASUREMENT PROTOTYPE IN THE TINKERCARD


PROGRAM
40

9.2. Arduino code

#include <Wire.h>

#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 16, 2);

float calibration_value = 22.9;

float ph_act =0;

float avgval, mean, stddev, maxval, minval, median;

float buffer_arr[20], temp;

float arr_level[10];

volatile long pulse;

unsigned long lastTime;

const int sensorPin = 2;

const int trigPin = 9;

const int echoPin = 8;

float volume = 0;

int base_area = 169;

float pipe_diameter = 2.1;

void setup() {

pinMode(sensorPin, INPUT);
41

pinMode(trigPin, OUTPUT);

pinMode(echoPin, INPUT);

attachInterrupt(digitalPinToInterrupt(sensorPin), increase, RISING);

Serial.begin(9600);

lcd.init();

lcd.init();

lcd.backlight();

lcd.setCursor(0, 0);

lcd.print("SYSTEM ");

lcd.setCursor(0, 1);

lcd.print("MEASUREMENT");

delay(2000);

lcd.clear();

lcd.setCursor(0, 0);

lcd.print("-STARTING");

lcd.setCursor(0, 1);

lcd.print("...");

delay(2000);

lcd.clear();

}
42

void loop() {

for (int i = 0; i < 20; i++) {

buffer_arr[i] =-0.03218391*(analogRead(A0)-1023)+2.8;

Serial.println(analogRead(A0));

lcd.setCursor(0, 0);

lcd.print("TAKING");

lcd.setCursor(0, 1);

lcd.print("SAMPLES");

lcd.setCursor(12, 1);

lcd.print(i*5);

lcd.setCursor(15, 1);

lcd.print("%");

delay(700);

lcd.clear();

lcd.setCursor(0, 0);

lcd.print("EVALUATING");

lcd.setCursor(0, 1);

lcd.print("RESULTS");

delay(1000);

avgval = 0;
43

for (int i = 0; i < 20; i++) {

avgval += buffer_arr[i];

float mean = (float)avgval / 20;

for (int i = 0; i < 19; i++) {

for (int j = i + 1; j < 20; j++) {

if (buffer_arr[i] > buffer_arr[j]) {

temp = buffer_arr[i];

buffer_arr[i] = buffer_arr[j];

buffer_arr[j] = temp;

stddev = 0;

for (int i = 0; i < 20; i++) {

stddev += sq(buffer_arr[i]-mean);

stddev = stddev/(20-1);

stddev = sqrt(stddev);

median=(buffer_arr[10]+buffer_arr[11])/2;

maxval= buffer_arr[19];

minval = buffer_arr[0];
44

ph_act = mean;

lcd.clear();

lcd.setCursor(0, 0);

lcd.print("PH CALCULATED:");

lcd.setCursor(4, 1);

lcd.print(ph_act);

delay(2000);

lcd.clear();

lcd.setCursor(0,0);

lcd.print("AVERAGE:");

lcd.setCursor(0,1);

lcd.print(mean);

lcd.setCursor(0,0);

lcd.print("STANDARD DEV.:");

lcd.setCursor(0,1);

lcd.print(stddev);

delay(2000);

lcd.clear();

lcd.setCursor(0,0);

lcd.print("MEDIAN :");

lcd.setCursor(0,1);

lcd.print(median);
45

delay(2000);

lcd.clear();

lcd.setCursor(0,0);

lcd.print("MAX. VALUE:");

lcd.setCursor(0,1);

lcd.print(maxval+0.05);

delay(2000);

lcd.clear();

lcd.setCursor(0,0);

lcd.print("MIN. VALUE:");

lcd.setCursor(0,1);

lcd.print(minval-0.03);

delay(2000);

lcd.clear();

evaluate_flow();

evaluate_level();

evaluate_ph();

lcd.clear();

lcd.setCursor(1,0);

lcd.print("Calculated Time");

delay(2000);

while(true){
46

time_calculation();

void evaluate_flow(){

int y=0;

while(y != 10){

volume = 2,663 * pulse;

if (millis() - lastTime > 1000) {

pulse = 0;

lastTime = millis();

lcd.clear();

lcd.setCursor(0, 0);

lcd.print("FLOW:");

lcd.print(volume);

lcd.print("mLxs");

delay(2000);

lcd.clear();

y+=1;

}
47

void evaluate_level(){

int y = 0;

while(y != 5){

float area = 112.0;

float max_level=100.0;

float min_level=0.0;

digitalWrite(trigPin, LOW);

delayMicroseconds(2);

digitalWrite(trigPin, HIGH);

delayMicroseconds(10);

digitalWrite(trigPin, LOW);

long duration = pulseIn(echoPin, HIGH);

float distance_cm = duration / 58.2;

level_arr[0] = 15.14-distance_cm;

Serial.println(arr_level[0]);

lcd.setCursor(0,0);

lcd.print("DISTANCE:");

lcd.setCursor(0,1);

lcd.print(distance_cm);
48

lcd.setCursor(7,1);

lcd.print("cm");

delay(2000);

lcd.clear();

lcd.setCursor(0,0);

lcd.print("LEVEL :");

lcd.setCursor(0,1);

lcd.print(abs(arr_level[0]));

lcd.setCursor(7,1);

lcd.print("cm");

delay(2000);

lcd.clear();

lcd.setCursor(0,0);

lcd.print("LIQUID:");

lcd.setCursor(0,1);

lcd.print(String(abs(arr_level[0]) *area,1));

lcd.setCursor(7,1);

lcd.print("ml");

delay(2000);

lcd.clear();

y+=1;
49

void evaluate_ph(){

String texto_0 = "Highly acidic";

String texto_1 = "Very acidic";

String text_2 = "Acid ";

String text_3 = "Neutral ";

String texto_4 = "Alkaline ";

String texto_5 = "Very alkaline ";

String text_6 = "Highly";

if (ph_act<4) {

lcd.clear();

lcd.setCursor(11,1);

lcd.print(ph_act);

lcd.setCursor(0,0);

lcd.print(text_0);

delay(2000);

lcd.clear();

}
50

if (ph_act>=4 && ph_act<6) {

lcd.clear();

lcd.setCursor(11,1);

lcd.print(ph_act);

lcd.setCursor(0,0);

lcd.print(text_1);

delay(2000);

lcd.clear();

if (ph_act>=6 && ph_act<6.5) {

lcd.clear();

lcd.setCursor(11,1);

lcd.print(ph_act);

lcd.setCursor(0,0);

lcd.print(text_2);

delay(2000);

lcd.clear();

if (ph_act>=6.5 && ph_act<7.5) {

lcd.clear();

lcd.setCursor(11,1);

lcd.print(ph_act);

lcd.setCursor(0,0);
51

lcd.print(text_3);

delay(2000);

lcd.clear();

if (ph_act>=7.5 && ph_act<8) {

lcd.clear();

lcd.setCursor(11,1);

lcd.print(ph_act);

lcd.setCursor(0,0);

lcd.print(text_4);

delay(2000);

lcd.clear();

if (ph_act>=8 && ph_act<10) {

lcd.clear();

lcd.setCursor(11,1);

lcd.print(ph_act);

lcd.setCursor(0,0);

lcd.print(text_5);

delay(2000);

lcd.clear();

}
52

if (ph_act>=10 && ph_act<14) {

lcd.clear();

lcd.setCursor(11,1);

lcd.print(ph_act);

lcd.setCursor(0,0);

lcd.print(text_6);

lcd.setCursor(0,1);

lcd.print("alkaline");

delay(2000);

lcd.clear();

void increase() {

press++;

void time_calculation(){

digitalWrite(trigPin, LOW);

delayMicroseconds(2);

digitalWrite(trigPin, HIGH);

delayMicroseconds(10);

digitalWrite(trigPin, LOW);
53

long duration = pulseIn(echoPin, HIGH);

float distance_cm = duration / 58.2;

float level = 15.14-distance_cm;

Serial.println("Level: "+String(level));

float calculated_volume = base_area*level;

Serial.println("Volume: "+String(calculated_volume));

float flow_rate = sqrt(2*9.81*level);

Serial.println("Output Flow: "+String(flow_rate));

float volumetric_flow = flow_speed*3.1415*pipe_diameter*pipe_diameter*0.25;

Serial.println("Volumetric Flow: "+String(volumetric_flow));

float calculated_time = calculated_volume/volumetric_flow;

Serial.println("Calculated Time: "+String(calculated_time));

delay(1000);

if(pulse>=2){

lcd.setCursor(1,1);

lcd.print(String(calculated_time,2)+" s");

lcd.setCursor(8,1);

lcd.print("-: "+String(calculated_time,2)+" s");

You might also like