Sunday, July 14, 2024

More results...

Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors
Search in posts
Search in pages

Microcontroller Projects: Sonar Water-Level Meter

BF6_TestThree-fourths of the earth is water, out of which 97 per cent is saline (in oceans, seas and groundwater). The remaining 2.5 per cent to 2.75 per cent is fresh water, out of which 1.75 per cent to two per cent is frozen in glaciers, ice and snow. Fresh groundwater and soil moisture constitutes only 0.7 per cent to 0.8 per cent. Less than 0.01 per cent, available as surface water in lakes, swamps and rivers, is available to us as drinking water. It is therefore imperative that systems are in place for managing this precious and scarce resource.

Water-level indicators for water-storage tanks are mostly mechanical contraptions. Steel wires, pulleys and rails get rusted as these are in continuous contact with water and air, resulting in unreliable operation. Contactless sonar-level metres are there but their high cost is a deterrent.

In this article, a sonar contactless, wireless water-level indicator, which can be fabricated for less than Rs. 2500, has been described. It is capable of measuring water levels up to four metres with an accuracy of less than 5mm.

Fig. 1: Circuit diagram of the transmitter unit
Fig. 1: Circuit diagram of the transmitter unit
Fig. 2: Circuit diagram of the receiver unit
Fig. 2: Circuit diagram of the receiver unit

Circuit and working

26C_PartsThe water-level indicator has two units: transmitter unit and receiver unit. The circuit diagram of the transmitter unit is shown in Fig. 1. It is built around ATmega328P microcontroller (MCU) (IC1) with Arduino Uno bootloader, sonar sensor HC-SR04 connected at CON1, 433MHz transmitter (TX1), voltage regulator 7805 (IC2) and a few other components. a long spiral antenna is used for enhancement of its range.

- Advertisement -

Attach the contactless sonar sensor at a strategic location on the tank so that it can always get the reflected signal from the water surface. The best place would be at the centre of a circular tank’s lid on top, or at the intersection of the diagonals of a rectangular tank’s top. The calculated tank level will then be transmitted with a coded authorisation to the receiver unit.

An ultrasonic ranging module provides 20mm to 5000mm non-contact measurement facility. Ranging accuracy is 3mm and aperture angle is 15°. Since we are measuring the level in centimetres in the form of an integer, our accuracy level is maximum 5mm. Even a 1cm level change will be seen very clearly, as every second it takes eight readings, which are then averaged out to get better accuracy.

Circuit diagram of the receiver unit is shown in Fig. 2. It is built around ATmega328P MCU (IC3) with Arduino Uno bootloader, voltage regulator 7805 (IC4), 4×16 alphanumeric display (LCD1), 433MHz receiver (RX1) and a few other components. The receiver checks the code word sent by the transmitter unit and displays the tank level on the LCD.

- Advertisement -

If the transmitter stalls or its power supply gets interrupted, there is no way for the receiver to find out that the incoming signal is no longer valid. To circumvent this problem, a counter has been provided on the right side of the LCD display. If the counter does not move, or it stops, it means that the incoming signal has stalled. Blinking of LED2 connected on pin 19 will stop, too.

Control relay and contactors can be connected on spare pins of ATmega328P, which finally controls the running of the water pump. Since there is no physical contact used in the sensory system, it will be operational without any interruption.

Fig. 3: Actual-size PCB pattern of the transmitter unit
Fig. 3: Actual-size PCB pattern of the transmitter unit
Fig. 4: Component layout of the PCB shown in Fig. 3
Fig. 4: Component layout of the PCB shown in Fig. 3
Fig. 5: Actual-size PCB pattern of the receiver unit
Fig. 5: Actual-size PCB pattern of the receiver unit
Fig. 6: Component layout of the PCB shown in Fig. 5
Fig. 6: Component layout of the PCB shown in Fig. 5

Download PCB and component layout PDFs: click here

Software comprises one remote_sonar_water_level_transmitter.ino file and one remote_sonar_water_level_receiver.ino file, besides some header files of Arduino. All are packed in the resource directory. Add these libraries to Arduino and upload the two files in the respective transmitter and receiver units.

Download source code: click here

Construction and testing

An actual-size, single-side PCB of the transmitter unit is shown in Fig. 3 and its component layout in Fig. 4. An actual-size, single-side PCB of the receiver unit is shown in Fig. 5 and its component layout in Fig. 6.

After assembling the two units, switch on the power supply of both the units. If the receiver receives the transmitted signal, LED2 will start blinking. The two small digit counters on the right top of the LCD will start changing and the water level (in centimetres) will show on the left-top position. Keep the small spiral antennae in vertical position to have the best radiation.

Somnath Bera is an avid user of open source software. Professionally, he is a thermal power expert and works as additional general manager at NTPC Ltd


  1. i am a little bit confused about the code files, as said do i have to upload two files reciever.ino and tranmitter.ino into reciever module and transmitter module through ATmeg programmer. secondly there are several files apart from above two files which files do i have to upload to arudino. should i have to use the programmer. kindly help

    • Yes, we can use any other programmer, in that case Arduino bootloader is not required. But this project is designed on Arduino Uno and so all the details given in this article are based on this.

      Arduino board comes with bootloader. If you need a fresh ATmega328 microcontroller with bootloader, they are easily available in the market or on Internet.

      There are three files for this project:

      1.remote_sonar_water_level_receiver.ino — to be downloaded in the receiver controller with Arduino boot loader
      2.remote_Sonar_water_level_transmitter.ino — to be downloaded in the transmitter controller with Arduino boot loader — this library file is to be used/added before compilation of above two files in Arduino IDE

      The receiver and transmitter programs are to be compiled using Arduino IDE. Take out the respective controller from Arduino board and use in your circuit.

  2. Sir,
    Please provide code for switching relay based on level (user programmable) include sump sensor + dry run sensor (all non-contact sensors). Also the changes in circuit diagram.

    Thank you in advance

  3. Really nice article and an innovative idea. Can you clarify the following:

    1. What would be the range of the RF signal, ie, maximum separation between the TX and RX?
    2. Would it be required to calibrate the sonar sensor?
    3. When we have several Overhead tanks, is it possible to instal identical kits in all the tanks and monitor from one place?
    4. Is there any readymade kit available in EFY or elsewhere?

    • Hi Mr Sagar,

      Thanks for the interest in my project.
      Your answers are like this…

      1> 100 meter.
      2> Not really. Considering the medium is not hermetically sealed or the medium has free access with the open ambient
      atmosphere such that the sonic velocity is not drastically changed !
      3> Yes, possible and in that case maintain a series of ID codes with all the Transmitters and then get them on a single receiver and then segregate them ID wise. Change the Tx & Rx code accordingly. This is a good suggestion to extend the horizon of this project. If there is taker , I can build the same.
      4> This I really don’t know.

  4. Dear Mr.Bera sir,
    Thanks for the wonderful design of the Sonar Water Level meter project. I would like to give my feedback regarding this. Since ATmega328P is used we have to get it with Bootloader already loaded, which is not always possible. So instead I request to please give us the same project with AT89S52 MC unit a user friendly and easily available one. So the code for HC SR04 and Tx&Rx also to be changed accordingly. I believe that you will consider this and do the needful to enable us to get it. Once again thanks a lot.

  5. hey sir i really appreciate your work but the thing is that i dont know how the coding is done and how is it going to show us the level of water like is it having any display or what???

  6. Hi Sir,
    I am very much interested in this project . (Sonar Water level meter). Can you please guide me how to proceed to do this project. Is there any prototype model available . Please guide .Or will i get PCB board for tihs.
    M Kishore.


Unique DIY Projects

Electronics News

Truly Innovative Tech

MOst Popular Videos

Electronics Components