Water Level Indicator Using Arduino & Ultrasonic Sensor

john February 17, 2018 11 Comments

Water Level Indicator Using Arduino

Wireless Water Level Indicator Using Ultrasonic sensor & Arduino is an amazing and very useful project. The objective of this project is to notify the user the amount of water that is present in the overhead water tank. This project can be further enhanced to control the water level in the tank by turning it ON, when the water level is LOW, and turning it OFF when the water level is HIGH. Thus, the Arduino water level indicator helps in preventing wastage of water in overhead tank. This project is wireless so, it is easy to install and it can work up to 100 meters.

In this project two circuits are used: a transmitter circuit and a receiver circuit. The transmitter circuit makes use of an ultrasonic sensor to measure the water level in terms of distance. This data is sent to the receiver circuit using RF communication. The water level is shown in terms of percentage on a 16×2 LCD module, which is connected to receiver circuit.

Components Used

ComponentsSpecificationQuantity
ArduinoNano2
Ultrasonic SensorHC-SR041
RF Transmitter Receiver PairASK 4331
LCD 16x21
Preset10K1
SwitchDPDT (PCB Mount)2
Battery9 Volt2
Battery Holder2

Working

In the project two circuits are used, First is the transmitter and second is the receiver. An Ultrasonic sensor is used in the transmitter circuit, which measures the distance of water level from the upper point of the bottle or Tank. The distance is measured in centimeters and sent to receiver circuit using RF communication.

Arduino Water Level Indicator

Arduino Water Level Indicator

 

Receiver circuit receives the data from transmitter circuit and converts it in terms of the percentage and shows on LCD.

Water Level Indicator Using Arduino

Water Level Indicator Using Arduino

 

Ultrasonic sensor has two openings, one is Trigger and the other is Echo. Trigger makes high frequency sound waves. These sound waves are passed through the tank from top to bottom. The sound waves hit the water and are reflected back in the form of Echo waves. The Echo opening receives the Echo waves. The water level sensor Arduino measures the time between Echo and Trigger. This traveled distance is directly proportional to the time.

Water Level Indicator Using Ultrasonic Sensor

Water Level Indicator Using Ultrasonic Sensor

Water Level Indicator Using Arduino – Video Demonstration

Arduino Water Level Indicator Circuit

In this project two circuits are used

  • Transmitter Circuit -   Transmitter circuit is shown in the figure below. Fig1, in this circuit an Ultrasonic sensor is connected to pin D9 and D10 pin of Arduino. Ultrasonic sensor is powered by Vcc and GND pin, these pins are connected to Vcc and GND pin of the Arduino. The measured data is transmitted by RF transmitter. RF transmitter’s data pin is connected to D4 pin of Arduino Nano. RF transmitter’s Vcc and GND pins are connected to Vcc and GND pins of the Arduino. In this transmitter circuit an Antenna is used which is connected to ANT pin of RF transmitter, whole circuit is powered by 9 volt battery. The battery is connected to Vin and GND pin of Arduino.
Water Level Indicator Using Arduino - Transmitter Circuit

Water Level Indicator Using Arduino – Transmitter Circuit

 

  • Receiver Circuit - In the receiver Circuit, RF Receiver is used for receiving data from the transmitter. Data pin of RF Receiver is connected to D4 pin of Arduino. Water level is shown on LCD and LCD is connected to Arduino from pin D4 to D9. LCD is powered by Vcc and GND pin using the Arduino, the contrast of LCD is changed by moving the preset, which is connected to pin 3 of LCD. Receiver circuit is powered by a 9 Volt battery through a switch, which is connected between Vcc and GND pin of the Arduino. Circuit is shown in the figure below.
Water Level Indicator Using Arduino - Receiver Circuit

Water Level Indicator Using Arduino – Receiver Circuit

 

The above shown circuit diagrams of transmitter and receiver circuits are more than enough to make one by yourself on a breadboard or Zero PCB.

If you are good in PCB Etching, you can use the images given below.

Water Level Indicator Using Arduino - PCB Design

Water Level Indicator Using Arduino – PCB Design

 

Water Level Indicator Using Arduino - PCB

Water Level Indicator Using Arduino – PCB

 

RF Receiver

RF Receiver

 

RF Transmiitter

RF Transmiitter

Program/Code

Download – Program for Water Level Controller (Transmitter)

Download – Program for Water Level Controller (Receiver)

In this project two circuits are used, both are powered by Arduino Nano. RF module is used for the communication between the Transmitter and the Receiver circuits.

How to Attach Library

  1.  Download the library file from the link https://github.com/sui77/rc-switch.
  2. Extract the file rc-switch-master.
  3. Copy the folder inside rc-switch-master folder.
  4. Paste the folder at location Documents> Arduino> library.
  5. Close the Arduino IDE software (if opend).
  6. Open the Arduino IDE.
  7. Click on file >Example
  8. If library is attached, you can see the rc-switch-master in Example list.

Transmitter

In the coding of the transmitter side, two header files are used. First is RCSwitch.h, which is used for RF transmitter and the second is Ultrasonic.h, which is used for the ultrasonic sensor.

Now pins of ultrasonic sensor is declared by the name ultrasonic in line 4, pin11 is Trig and pin10 is Echo. In the line 5 RCSwitch is declared for the transmitter by name “mySwitch”. In the line 7 an integer is declared by the name “i”.

In the void setup Transmitter is enabled by function “mySwitch.enableTransmit(4)”, where transmitter’s data pin is connected to pin D4 of the Arduino.

In the void loop, the distance is measured by function “ultrasonic.Ranging(CM)” and it is assigned in integer “I”, this distance is measured in centimeters.

In the line 15, the measured distance is transmitted by function “mySwitch.send(i, 24)”, where “i” is the distance and 24 is the bit format. After all “delay” of 100 milliseconds are used, which means Arduino sends the data after every 100 milliseconds.

Receiver

In the receiver side, two header files are used, The first is “RCSwitch.h” which is used for RF communication between the Transmitter and the Receiver and the second is “LiquidCrystal.h”, which is used for LCD display.

In the line 4, Arduino pins are declared, which are connected to LCD. Total 6 pins are connected to Arduino that are D4, D5, D6, D7, D8, D9. In the line 5, “RCSwitch” is declared by the name “mySwitch”.

In the line 7, a float is declared by the name “level”, which shows the water level and in the line 9 and 10 two integers are declared by name “Hval” and “Lval” where, “Hval” is the upper value of water level (distance from ultrasonic sensor) and “Lval” is the Lower value of water level (distance from ultrasonic sensor). After all pin of buzzer is declared by integer “BUZZER” where, 10 is the D10 PIN of Arduino.

In the void setup RF Receiver is enabled by function “mySwitch.enableReceiver(0)”, where 0 is the interrupt pin (INT0) which is D2 pin of Arduino.

In the line 16, LCD begins by function “lcd.begin(16, 2)”, and in line 17, “lcd.print” is used for showing “WATER LEVEL INDI” in the first row of LCD.

In the line 19, “pinMode(BUZZER, OUTPUT)” declares the BUZZER pin as OUTPUT.

In the “void loop()” in the begening “if (mySwitch.available())” is used, that means if any data is received from RF Receiver, the program come in the loop. In the line 25, data coming from RF Receiver is decoded by function “mySwitch.getRecivedValue” and saved in a float “level”.

In the line 27 and 28 the “level” is processed and converted into the percentage, by using some mathematical expression. In line 30, “If” condition is used for limitation of percentage.

In the line 32, 33, 34, 35 the level is print on the LCD and in the line 37 “mySwitch.reset.Available()” function is used for resetting the RF module.

In the end of the code, “If” condition is used for switching on the buzzer, if level become more then 99 percentage.

 

 

 

 

 

Comments
  • June 24, 2019

    Hey, how’s it going?

    I want to pass along some very important news that everyone needs to hear!

    In December of 2017, Donald Trump made history by recognizing Jerusalem as the capital of Israel. Why is this big news? Because by this the Jewish people of Israel are now able to press forward in bringing about the Third Temple prophesied in the Bible.

    Jewish Rabbis have publicly announced that their Messiah will be revealed in the coming years who will be a leader and spiritual guide to all nations, gathering all religions under the worship of one God.

    Biblical prophecy tells us that this Jewish Messiah who will take the stage will be the antichrist “who opposes and exalts himself above all that is called God or that is worshiped, so that he sits as God in the temple of God, showing himself that he is God” (2 Thessalonians 2:4). For a time he will bring about a false peace, but “Therefore when you see the ‘abomination of desolation,’ spoken of by Daniel the prophet, standing in the holy place (Matthew 24:15)…then there will be great tribulation, such as has not been since the beginning of the world until this time, no, nor ever shall be” (Matthew 24:21).

    More importantly, the power that runs the world wants to put a RFID microchip in our body making us total slaves to them. This chip matches perfectly with the Mark of the Beast in the Bible, more specifically in Revelation 13:16-18:

    “He causes all, both small and great, rich and poor, free and slave, to receive a mark on their right hand or on their foreheads, and that no one may buy or sell except one who has the mark or the name of the beast, or the number of his name.

    Here is wisdom. Let him who has understanding calculate the number of the beast, for it is the number of a man: His number is 666.”

    Referring to the last days, this could only be speaking of a cashless society, which we have yet to see, but are heading towards. Otherwise, we could still buy or sell without the mark amongst others if physical money was still currency. This Mark couldn’t be spiritual because the word references two different physical locations. If it was spiritual it would just say in the forehead. RFID microchip implant technology will be the future of a one world cashless society containing digital currency. It will be implanted in the right-hand or the forehead, and we cannot buy or sell without it. Revelation 13:11-18 tells us that a false prophet will arise on the world scene doing miracles before men, deceiving them to receive this Mark. Do not be deceived! We must grow strong in Jesus. AT ALL COSTS, DO NOT TAKE IT!

    “Then a third angel followed them, saying with a loud voice, “If anyone worships the beast and his image, and receives his mark on his forehead or on his hand, he himself shall also drink of the wine of the wrath of God, which is poured out full strength into the cup of His indignation. He shall be tormented with fire and brimstone in the presence of the holy angels and in the presence of the Lamb. And the smoke of their torment ascends forever and ever; and they have no rest day or night, who worship the beast and his image, and whoever receives the mark of his name” (Revelation 14:9-11).

    People have been saying the end is coming for many years, but we needed two key things. One, the Third Temple, and two, the technology for a cashless society to fulfill the prophecy of the Mark of the Beast.

    Visit http://WWW.BIBLEFREEDOM.COM to see proof for these things and why the Bible truly is the word of God!

    If you haven’t already, it is time to seek God with all your heart. Jesus loves you more than you could imagine. He wants to have a relationship with you and redeem you from your sins. Turn to Him and repent while there is still hope! This is forever…God bless!

    “EITHER HUMAN INTELLIGENCE ULTIMATELY OWES ITS ORIGIN TO MINDLESS MATTER OR THERE IS A CREATOR…” – JOHN LENNOX

    We all know God exists. Why? Because without Him, we couldn’t prove anything at all. Do we live our lives as if we cannot know anything? No. So why is God necessary? In order to know anything for certain, you would have to know everything, or have revelation from somebody who does. Who is capable of knowing everything? God. So to know anything, you would have to be God, or know God.

    A worldview without God cannot account for the uniformity and intelligibility of nature. And why is it that we can even reason that God is the best explanation for this if there is no God? We are given reason to know or reject God, but never to know that He does not exist.

    It has been calculated by Roger Penrose that the odds of the initial conditions for the big bang to produce the universe that we see to be a number so big, that we could put a zero on every particle in the universe, and even that would not be enough to use every zero. What are the odds that God created the universe? Odds are no such thing. Who of you would gamble your life on one coin flip?

    Is there evidence that the Bible is the truth? Yes. Did you know that the creation accounts listed in the book of Genesis are not only all correct, but are also in the correct chronological order? That the Bible doesn’t say the Earth was formed in six 24-hour days but rather six long but finite periods of time? That the Bible makes 10 times more creation claims than all major “holy” books combined with no contradictions, while these other books have errors in them? The Bible stood alone by concurring with the big bang saying, “In the beginning God created the heaven and the earth” (Genesis 1:1); and says our universe is expanding, thousands of years before scientists discovered these things. Watch a potential life-changing video on the front page of http://WWW.BIBLEFREEDOM.COM with Astronomer(PhD) Hugh Ross explaining all these facts based on published scientific data. He has authored many books, backed even by atheist scientists.

    Jesus came to pay a debt that we could not; to be our legal justifier to reconcile us back to a Holy God; only if we are willing to receive Him: “For the wages of sin is death…” (Romans 6:23).

    God so loved the world that He gave us His only begotten son, so that whoever believes in Him, through faith, shall not perish, but have everlasting life. Jesus says if we wish to enter into life to keep the commands! The two greatest commands are to love God with all your heart, soul, strength, and mind; and your neighbor as yourself. All the law hang on these commands. We must be born of and lead by the Holy Spirit, to be called children of God, to inherit the kingdom. If we are willing to humble ourselves in prayer to Jesus, to confess and forsake our sins, He is willing to give the Holy Spirit to those who keep asking of Him; giving us a new heart, leading us into all truth!

    Jesus came to free us from the bondage of sin. The everlasting fire was prepared for the devil and his angels due to disobedience to God’s law. If we do the same, what makes us any different than the devil? Jesus says unless we repent, we shall perish. For sin is the transgression of the law. We must walk in the Spirit so we may not fulfill the lusts of the flesh, being hatred, fornication, drunkenness and the like. Whoever practices such things will not inherit the kingdom (Galatians 5:16-26). If we sin, we may come before Jesus to ask for forgiveness (1 John 2:1-2). Evil thoughts are not sins, but rather temptations. It is not until these thoughts conceive and give birth by our own desires that they become sin (James 1:12-15). When we sin, we become in the likeness of the devil’s image, for he who sins is of the devil (1 John 3:8); but if we obey Jesus, in the image of God. For without holiness, we shall not see the Lord (Hebrews 12:14).

    The oldest religion in the world is holiness through faith (James 1:27). What religion did Adam and Eve follow before the fall? Jesus, Who became the last Adam, what religion does He follow? Is He not holy? He never told us to follow the rituals and traditions of man but to take up our cross and follow Him (Luke 9:23). There are many false doctrines being taught leading people astray. This is why we need the Holy Spirit for discernment. Unlike religion, holiness cannot be created. It is given to us from above by the baptism of the Spirit. Jesus is more than a religion; He is about having a personal relationship with the Father. Start by reading the Gospel of Matthew, to hear the words of God, to know His character and commandments. Follow and obey Jesus, for He is the way, the truth, and the life!

  • Sushil
    September 28, 2018

    sir plz hlep. In my project counting start from 100% it reduce 90,80….
    i am using ur code..
    i want to start form 0.0% to 100%.
    how can i solve plz guide me…

  • Badshah
    June 21, 2018

    What modification shall I do to switch on/off the transmitter circuit from ground…???

  • Frank Katona
    April 26, 2018

    Does anyone offer for sale a completed project?

  • Frank Katona
    April 26, 2018

    Does anyone offer a completed transmitter and receiver with software loaded for sale?

  • Thomas Joseph
    March 25, 2018

    Dear Sir,

    Very interesting project and it is working fine … i have request on this program.

    As per this code motor turn ON water level less than “X” level, OK, the motor started pumping the water ;But in case lower tank was empty or some other reasons the TANK water level not increasing from the “X” level, we have to TURN OFF the motor for safety purpose.

    For example: current water level is >60 CM and motor is ON,BUT after 3 MIN still water level not increasing or not reached a specific level( Eg: 50CM) we have to turn of the motor .

    So this is my requirement how do I resolve this, could you please help me.

  • Fernando Leite
    January 3, 2018

    I could not find the library file “Ultrasonic.h” for download. Has anyone been able to download?

  • Bringa
    December 10, 2017

    Cool project, sadly the 9 volt is empty really fast

  • Hemant
    November 28, 2017

    Receiver program level percentage formula not in work 0-100% plz suggest me

  • Arshad
    November 20, 2017

    I was very excited to see this wireless monitor and decided to make for my overhead tank. Spent couple of bucks and got all components. All went smooth transmitter codes giving following error .

    Worth mentioning I am just beginner and a hobbyist hence followed every thing verbatim.

    Arduino: 1.8.5 (Windows 7), Board: “Arduino Nano, ATmega328P”

    C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\Arshad\Documents\Arduino\libraries -fqbn=arduino:avr:nano:cpu=atmega328 -ide-version=10805 -build-path C:\Users\Arshad\AppData\Local\Temp\arduino_build_192362 -warnings=default -build-cache C:\Users\Arshad\AppData\Local\Temp\arduino_cache_525437 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose C:\Users\Arshad\AppData\Local\Temp\arduino_modified_sketch_23154\Transmitter.ino
    C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\Arshad\Documents\Arduino\libraries -fqbn=arduino:avr:nano:cpu=atmega328 -ide-version=10805 -build-path C:\Users\Arshad\AppData\Local\Temp\arduino_build_192362 -warnings=default -build-cache C:\Users\Arshad\AppData\Local\Temp\arduino_cache_525437 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose C:\Users\Arshad\AppData\Local\Temp\arduino_modified_sketch_23154\Transmitter.ino
    Using board ‘nano’ from platform in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr
    Using core ‘arduino’ from platform in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr
    Detecting libraries used…
    “C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++” -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR “-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino” “-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\eightanaloginputs” “C:\Users\Arshad\AppData\Local\Temp\arduino_build_192362\sketch\Transmitter.ino.cpp” -o “nul”
    “C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++” -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR “-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino” “-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\eightanaloginputs” “-IC:\Users\Arshad\Documents\Arduino\libraries\rc-switch-2.6.2” “C:\Users\Arshad\AppData\Local\Temp\arduino_build_192362\sketch\Transmitter.ino.cpp” -o “nul”
    “C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++” -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR “-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino” “-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\eightanaloginputs” “-IC:\Users\Arshad\Documents\Arduino\libraries\rc-switch-2.6.2” “C:\Users\Arshad\AppData\Local\Temp\arduino_build_192362\sketch\Transmitter.ino.cpp” -o “C:\Users\Arshad\AppData\Local\Temp\arduino_build_192362\preproc\ctags_target_for_gcc_minus_e.cpp”
    C:\Users\Arshad\AppData\Local\Temp\arduino_modified_sketch_23154\Transmitter.ino:2:24: fatal error: Ultrasonic.h: No such file or directory

    #include

    ^

    compilation terminated.

    Using library rc-switch-2.6.2 at version 2.6.2 in folder: C:\Users\Arshad\Documents\Arduino\libraries\rc-switch-2.6.2
    exit status 1
    Error compiling for board Arduino Nano.

  • V. Hari Hara Prasad
    October 20, 2017

    Very good idea to measure the distance between water level and sensor. The transmitter and receiver circuits make sense of avoiding unnecessary wiring. We can also keep more sensors to measure the water pressure and tank filling log to tell the user approximate time to fill the tank. Same may be used to measure the fuel storage in a vehicle and approximate distance to travel for next filling: the average kmph calculation of the vehicle. A clock can also be added to show date, time and calendar.

Leave a Reply

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