Water Level Indicator and Controller using PIC Microcontroller

Here is a simple, versatile project which indicates the level of water and automatically controls it by using PIC Microcontroller. The Water Level Sensing Section senses the level of water in the tank and sends it (wireless) to the Receiver Section. Receiver Section is connected to the Controlling Section, which process the received information and produces visual, sound indications and controls the operation of the motor whenever required. The project is divide into 4 sections.

1. Power Supply Section

Power Supply section provides required supply for Receiver and Controlling modules. Receiver module requires +5V power supply. Controller module requires +5v and +12v supply. Circuit Diagram:

 2.Water Level Sensing Section

Circuit Diagram:

ASK RF Transmitter

ASK RF Transmitter

Level Sensor module is made of with HT12E encoder and ASK (Amplitude Shift Keying) RF transmitter. This circuit can be drive using 9V battery. For more details about this transmitter, please read the article Wireless RF Transmitter and Receiver using ASK RF Module. This circuit is placed near the Water Tank and connected to the tank as show in the figure below.

Water Tank Connections

Water Tank Connections

3. Receiver Section

Circuit Diagram:

ASK RF Receiver

ASK RF Receiver

 

Receiver Module is made of with HT12D decoder and ASK RF receiver. The data transmitted by the Sensor module is received by this module and is given to the Controlling Module. For more details about this receiver, please read the article Wireless RF Transmitter and Receiver using ASK RF Module.

4. Controlling Section

Circuit Diagram :

Water Level Indicator Controller using PIC Microcontroller

Water Level Indicator Controller using PIC Microcontroller

The soul of the Controlling Section is PIC16F877A. It process the data given by the Receiver Section. LCD Display, LED Indications and Motor status are updated according to the data. You can download the hex file and mikroC Source Code at the bottom of this article.

Working

For the transmission and reception of data we have used Holtek encoder-decoder pair of HT12E and HT12D. Both of them are CMOS ICs working voltage ranges from 2.4 to 12v. The oscillator resistances are chosen according to the datasheet. When water level raises, the data pins of the encoder will be grounded corresponding to the level of water, which will be transmitted to the Receiver via ASK RF module. The received data is decoded by the decoder HT12D. LED on the receiver indicates that it is receiving data. Then the data is given to the PIC for processing.

D0 D1 D2 D3 Status
0 0 0 0 All data pins are grounded, indicates tank is Full.
0 0 0 1 Water level is below D3 and above D2, indicates High level.
0 0 1 1 Water level is below D2 and above D1, indicates Medium level.
0 1 1 1 Water level is below D1 and  above D0, indicates Low level.
1 1 1 1 Water level is below D0, indicates Very Low level.

When the water level becomes Very Low, the motor will turned ON, buzzer sounds and the LCD backlight will automatically turned ON for 5 seconds. After this, when the water level reaches Full level, the motor will automatically turned OFF, buzzer sounds and the LCD backlight will automatically turned ON for 5 seconds. During normal operation you can manually turn on LCD backlight by pressing the Push button switch. The LCD indicates the Level of water (‘Very Low’, ‘Low’, ‘Medium’, ‘High’,’Full’) and the status of the motor (‘ON’ or ‘OFF’). The LED bar will also indicate the level of water. You can download the hex file, mikroC source code, PCB Design, Layout, Proteus and Orcad files here.

Waterlevel indicator controller

You may also like...

  • srikanth

    Dear friend how much distnce it will work

  • http://www.electrosome.com/ Ligo George

    More than 100m……..

  • Hirak Das

    dear friend pls tell me the crystal value
     

  • http://www.electrosome.com/ Ligo George

    You may use 4 or 8 MHz……

  • Sallysamantha5988

    can we get the programming of this project??

  • Ace Virgil Villaruz

    where can I buy the materials needed for this project?

  • http://www.electrosome.com/ Ligo George

    Do you mean the programmer to write program to PIC Microcontroller?

  • http://www.electrosome.com/ Ligo George

    You can get if from a good electronics shop……..

  • Sallysamantha5988

    Yes…can we get that  programmer languange? thank you..

  • http://www.electrosome.com/ Ligo George

    Do you mean programmer or compiler?

    The programming is done by using MikroC Compiler….
    You can download the trial version from their site : http://www.mikroe.com/mikroc/pic/

    Trial version is sufficient for this….

  • Sallysamantha5988

    ok.tqvm..

  • http://www.electrosome.com/ Ligo George

    I have included the source code along with the zip file…………

  • Sallysamantha5988

    what others software that i need to used in this project,except for the microC pro software??because i found that i can’t open some sourcecode in the Zip file..

  • http://www.electrosome.com/ Ligo George

    programming is done using mikroc pro…….

    the circuit can be simulated using Proteus and PCB designing is done using Orcad 9.1 whose files are included in the zip file…

  • http://profile.yahoo.com/I2DH5SDPPJPJPYQ26FKDDNFJKE Md.

    I completed this project in bread board , connect the all component correct connection but Transmitting or Receiving system does not work properly. Hang up always indicate Level: Full, Motor OFF. How could i solve this problem? plz help me……….

  • http://www.electrosome.com/ Ligo George

    Check the transmitting and receiving circuit……….The LED in the receiving circuit will glow when it receives signals from the transmitting circuit……..

  • Modasser_84

    I face a new prob……when I D0 throw ground Level: Low , Motor ON. but when D1 is grounded Its showed Level: Very Low,Motor On. after that D2,D3 grounded Level:”  “, Motor:”  “……….All the connection are correct and ok…………but when I remove D1 from receiver of decoder Its work proper but D0 is showed both level: Low/Medium.and finally D2,D3 was showed correct data…… now what should i do…..plz help me..The LED in the receiving circuit is glowing……….. 

  • http://www.electrosome.com/ Ligo George

    There are only 5 valid conditions for D0, D1, D2, D3
    as shown in the table given in the article………Please refer it……….Un-implemented inputs may generate un-predictable outputs……….

  • Modasser_84

     I understand ……..bt the receiver of decoder D1 is always shown +5 volt it doesnt generate 0 volt is it the decoder IC problem??????????? I gave implement input…..D0,D1,D2,D3 (Close)……by the reverse condition D3, D2,D1,D0 (Open) Isnt correct loop????????

  • http://www.electrosome.com/ Ligo George

    It may be the decoder or encoder IC probelm………check with another IC …….also check for unwanted shots………..
    I don’t understand the last sentence you said….

  • sumonrashid
  • http://www.facebook.com/lijoppans Ligo George

    Variable C is used to light led backlight when switch is pressed or when motor on off conditions occur………b is used to sound the buzzer 3 times……….

  • bentancc

    Hi, could this project be modified to read diesel tank level instead of water?

  • http://www.electrosome.com/ Ligo George

    No, it is dangerous……………..

  • A.Faisal

    hi. I feel curious about the tx and rx circuit. I found one RX and TX module, but the leg is not same. If i use that, still can work or not?

  • http://www.electrosome.com/ Ligo George

    If it is ASK TX and RX you can connect HT12D and HT12E to its appropriate pins

  • A.Faisal

    ok. thank you. btw, this project is really working right? in term of rx and tx circuit.

  • http://www.electrosome.com/ Ligo George

    Yes it is working perfectly ….. You can buy the rf transmitter & receiver online from extereme electronics or robokits…

  • A.Faisal

    Thanks. I will post it to you when its working. Btw, I’m looking forward to work with you with other project. Maybe we can work together.

  • http://www.electrosome.com/ Ligo George

    Yes, of course……

  • Simba

    how do you pair the two or there is no need to pair the two they will automatically pair?

  • http://www.electrosome.com/ Ligo George

    You mean transmitter & receiver? ……. Encoder and Decoder IC contains Address pins A0 – A7…… in both transmitter and receiver, status of these address pin should be same……

  • Simba

    yes I meant the transmitter and receiver. I want to use the two for wireless sensor monitoring connected to the Arduino uno. Thanks for the response

  • Tommy

    How i can change the programming using mplab??

  • FARISH

    HOW CAN I BURN THE PROGRAM TO IC….?

  • http://www.electrosome.com/ Ligo George

    You need a PIC Programmer for writing program to pic..

  • http://www.electrosome.com/ Ligo George

    Take the logic from mikroc and convert it to mplab..

  • Rochelle April

    Hi, would like to ask if do you have a code for this ? I want to try this in virtual breadboard. We have a finals for PIC Microcontroller, and I’m searching for easier but working one :) Looking forward to your reply. Thanks and Godbless.

  • http://www.electrosome.com/ Ligo George

    Yes you can download codes etc from above link……..

  • Rochelle April

    Hi. I don’t get the code, sorry, I’m new to vb. I’m working to understand but it’s so hard. When I try to assemble your wli.asm file you provided, it has 400errors. And I don’t know what lines causes the errors.

    And may I know please if what is its processor used?

    like the sample code below:

    processor 16f84
    #include
    __config _RC_OSC & _WDT_OFF & _PWRTE_ON
    STATUS equ 03h ;define address for the status register
    TRISA equ 85h ;define address for the tristate register for port A
    PORTA equ 05h ;define address of port A
    TRISB equ 86h ;define address for the tristate register for port B
    PORTB equ 06h ;define address of port B
    ORG 0×000
    BSF STATUS,5 ;switch to bank1
    MOVLW B’00000000′ ;set port B as output port
    MOVWF TRISB
    MOVLW B’11111′ ;set port A as input port
    MOVW TRISA
    BCF STATUS,5 ;switch back to bank0

    start
    MOVLW 01h
    MOVWF PORTB
    GOTO start
    END

    Pardon to have so much questions. Just want to understand it, hope you helps ♥ thanks.

  • farish

    what is the ‘contast 100′ in the circuit….?
    and what type of switches that we have to use in place of ‘reset’ and’manual lcd backlight’?

  • http://www.electrosome.com/ Ligo George

    It is a variable resistor use 10K, used to adjust the contrast of LCD……. You can use micro switches ,,,

  • http://www.electrosome.com/ Ligo George

    That is a MikroC program written for PIC 16F877A microcontroller…….

  • farish
  • http://www.electrosome.com/ Ligo George

    You can download the entire project files from the above download link…..

  • http://www.facebook.com/tommy.ukat Tommy Ukat

    my circuit is already operation, but my problem now. i don know how to convert the programming to mplab because we study using the mplab..i dont have the converter and programer to install the programming in pic using mikroc… can u xplain more detail step to convert the programming to me.. or if u have the programming in mplab.. can email me [email protected].. tq

  • http://www.electrosome.com/ Ligo George

    You can write the hex file to the pic microcontroller in the downloaded zip file using a pic programmer…….if you want to convert the program to mplab……. take the logic of mikroc and write your own code……..

  • nimra

    hey, what changes will be required if motor work is excluded i want only indication in lcd

  • http://www.electrosome.com/ Ligo George

    Remove the relay and its driving circuits……….
    LCD indications include motor on off status……. you can remove this by editing the program…

  • abhay

    wat is the crystal value???

  • http://www.electrosome.com/ Ligo George

    8MHz

  • steve

    hi can we use a cheaper or smaller mcu ? and how to modify the program

  • http://www.electrosome.com/ Ligo George

    Yes, of course..
    You may use 8051
    But PIC is also cheaper, PIC16F877A costs below 3$..

  • Nibhath

    Hey Ligo,I wish to implement water level controller based on 16F877A PIC microcontroller. Important thing that detect the water level continuously using vertical float switch sensor.It gives output as resistance.I would like to know how float switch sensor apply to this system and how mikroc program for relevant change…Looking forward to your reply ASAP..thanks friend…

  • http://www.electrosome.com/ Ligo George

    You need to use an ADC….. Since wireless communication via RF module is required… only discrete values are possible.. from 0000 to 1111… total 16 discrete values possible… If you need more accuracy it will become more complex…

  • Nibhath

    In this system has one of particular water level unlike site having system.System design to maintain that particular water level.The tank contain inlet and outlet in order to insert water into tank and eliminate water from tank.Inlet and outlet should be activate when water level goes below and above of that particular water level separately.I wish to deploy this into paddy field.Since there require predefined water level for each mtime period.Your system having discrete water level is not practical when implement to paddy field.That’s why i selected float switch.I want to know about mikroc program of control section and how it change when apply float into this system..Look forward your reply…Thanks Ligo

  • vinutha

    sir can you please provide me with the complete code for the project.. its little urgent, as ma presentation is this weekend :(

  • http://www.electrosome.com/ Ligo George

    There is an option to download the complete project files… above…

  • faisal

    Hi Ligo. Long time no see. For your information, I already build up the circuit. Left things is to program the circuit into PIC. I just want to know, the 12V power source is necessary or not? because I dont see 12 V power supply connected to circuit that you created for simulation.

  • http://www.electrosome.com/ Ligo George

    12V is used to operate the relay that used to control the motor… If you wish to use 5V relay, then you can avoid 12V.. I think 5V relays for handling high currents are not available..

  • faisal

    i see. another thing, seeing the 5V as primary power supply for the controller circuit, is it sufficient to power up all the components eg PIC, level LED, LCD screen. FYI, i tried to make the PIC used the stand-alone power supply which is 5V, but not working. If i connected it to one source only, it lit up but somehow the display fluctuated. keep resetting.

  • http://www.electrosome.com/ Ligo George

    Yes, that 5V power supply is enough…. You should add enough filtering capacitors to avoid ripples as shown in the power supply circuit diagram..

  • Cyn

    My proteus is working but led didn’t light up and hardware for led n LCD also didn’t light up

  • Cyn

    By the way do u hav an actual circuit for me to see the connections?

  • http://www.electrosome.com/ Ligo George

    The above circuit is the actual one.. VDD and VSS of the pic microcontroller is not shown in that circuit diagram.. VDD should be connected to 5V and VSS should be connected to ground..

  • http://www.electrosome.com/ Ligo George

    You might not have connected VDD and VSS of PIC microcontroller which is not show in the circuit diagram.. Actually VDD and VSS are hidden in proteus.. anyway I will modify the above circuit diagram by including VDD and VSS..

  • Faraz Khan

    Please tell me whether, can i use this RF transmitter and receiver with the above circuit? ASK RF transmitter and receiver are not available in my area.

    kindly reply soon.

  • http://www.electrosome.com/ Ligo George

    This might be differs only in pin diagram.. I think so.. You can buy RF modules that I used from many online stores.. just search it…

  • Faraz Khan

    can i use 20 MHz crystal ??

  • http://www.electrosome.com/ Ligo George

    Yes … ofcourse…. change the clock frequency to 20MHz in the project settings and Build it again…

  • Faisal

    hi George, I want to ask, the output on decoder circuit is on what type? HI LOW or in binary number?

  • http://www.electrosome.com/ Ligo George

    Actually, I don’t get your question… All binary numbers are represented using HIGH and LOW (here it is 5V and 0V)…

  • prakasha

    how to dowload the code.

  • http://www.electrosome.com/ Ligo George

    Don’t you see the above download link. You must login to download it.. Please register and login, its free..

  • Faisal

    George, one more thing, the RX will read input from each respective pins and give data to correspondence pins on decoder right? Eg: pin 10 on encoder take data from tank, and the data will be transmitted and give that data at pin 10 on decoder. Am I correct? If I’m correct, than my project actually faced problem with this thing, where, if one pin of DATA IN on encoder take reading from the tank, then, the all DATA OUT on decoder give HIGH. Hope you can help me. I did troubleshooting many times including changing ICs, TX and RX, osc value etc.

  • http://www.electrosome.com/ Ligo George

    HT12E – Encoder – (Data In) Reads data from water tank and gives it serially to RF Transmitter……..
    HT12D – Decoder- RF Receiver Receives data transmitted by Transmitter and it is given (serial data) to HT12E- it decodes it in to parallel output (Data Out)

  • Faisal

    OK, but seem, the output is not really good, where in case LOW level is detected, but, all output at HT 12D is HIGH. so how?

  • http://www.electrosome.com/ Ligo George

    Does the LED in the receiver circuit glows when the transmitter circuit is turned ON?
    That LED indicates that the receiver circuit is receiving data from transmitter….
    You might have burned the encoder or/and decoder by misplacing them..

  • Faisal

    Yes, it does glow. Here is another problem, why everytime it read data from RX, it always reset? Sometime, when controller read HIGH to MEDIUM, then the controller reset again, not live feed.

  • http://www.electrosome.com/ Ligo George

    I don’t get what you said..

  • SRI

    Dear Friend What is the Configuration of PIC16F877A

  • http://www.electrosome.com/ Ligo George

    Here is mikroc project settings.

  • Atchai

    can we use ir transmitter insteed of rf transmitter?>What’s difference between both?

  • http://www.electrosome.com/ Ligo George

    Yes you may use….
    . IR –> Infrared
    RF —> Radio frequency..

    IR allows only Line Of Sight communication and less range.. RF has no such problems..

  • Regina Assuncion Adame

    good day.. i have a question.. where or in what pin im gonna connect the rf receiver to the pic16f877a.. sorry kinda new to this one..

  • http://www.electrosome.com/ Ligo George

    See the labels on data pins on pic and rf receiver (HT12D)…..

  • Regina Assuncion Adame

    oh i get it now.. i will put it on RA0- RA3.. thanks sir.. i have 1more question sir.. if i wil put uart converter or max232 and rs232 to connect it to serial port of the computer and display it through visual basic instead of the LCD.. will it be working?.. thank you

  • http://www.electrosome.com/ Ligo George

    Of course .. it will work…

  • Regina Assuncion Adame

    sir.. i edit the circuit diagram so i can interface it to the pc and visual basic.. is this correct..thanks

  • http://www.electrosome.com/ Ligo George

    There is a small mistake…….
    RX of PIC should be connected to TX of UART Converter..
    and..
    TX of PIC should be connected to RX of UART Converter..

    Hope you got it..

  • Regina Assuncion Adame

    ooppss..thank you sir…

  • Regina Assuncion Adame

    good day sir.. i would like to ask if how far will be the maximum distance of the rf transmitter to the receiver?.. thank you

  • http://www.electrosome.com/ Ligo George

    You can have about 100 meters range with proper antenna..

  • sophie

    that is good,but do i need two microcontrollers for receiver module and transmitter module or just one? if it only one PIC how is it connected to receiver and transmitter module.

  • sophie

    I would like to know also if i want to have multiple water tanks what should i do?

  • sophie

    how can use Proteus for simulation if the tanks are out of the site?

  • http://www.electrosome.com/ Ligo George

    You need only one microcontroller.. .which is used in receiver module

  • http://www.electrosome.com/ Ligo George

    you may use multiple transmitter/receiver with different frequencies..

  • http://www.electrosome.com/ Ligo George

    We can’t do proteus simultion.. since transmitter and receiver are not available in proteus library..

  • junaid ullah

    i need a circuit with out using rf antenna
    what should i do

  • http://www.electrosome.com/ Ligo George

    Without RF antenna?? Every RF wireless device should have an antenna to radiate energy..

  • Albin George
  • Albin George

    i need to add a manual switch to on the motor(When the water level is above medium or other case ). What changes i need to made to the code?

  • http://www.electrosome.com/ Ligo George

    VB Code??
    This project hasn’t any interface with PC..

  • http://www.electrosome.com/ Ligo George

    Simply connect a push button switch to a IO pin of PIC.. make that pin input … see our pic tutorials..

  • raj

    Hi Ligo, i couldnt get any thing on the LCD despite programming successfully with PICKIT2 using hex file you’ve provided.but the LEDS and buzzer are working in a continuous loop i dont understandwhat might be the reason there is nothing displayed on the LCD(rest everything including LCD backlight working,also I tried the contrast preset but nothing on the Lcd).please help.

  • http://www.electrosome.com/ Ligo George

    There might have some connection problems.. above circuit and program is 100% working..

  • Guest

    there is no download option ….please help in getting the code..

  • vijay

    will copper wires be efficient as sensors in this project??????

  • kotelo

    can I use PIC16F887 in this Project, if yes help in getting the source code

  • kotelo

    can I use PIC16F887A in this Project, if yes help in getting the source code

  • Antu

    can i use this controller without RF transmitter? i prefer normal sensor probes eg: float switch, will it work ?

  • Antu

    i made this wlc on a breadboard and it works fine.The only problem i found was there is no dry run protection for the motor..

  • Krishna

    No…. Due to current passing in the wires.. Because of electrolysis the copper will be eaten Up with a time less than 1 week. ( I Faced the same problem) “sorry fro bad english”

  • Mangala Kulasekera

    i have difficulties with programming of ic 16f877a. can i get programmed ic.

  • sunil

    this is not a complete water level controller. sump tank sensor is missing

  • Shri Kamble

    i got the whole program of this, comment your id here :D ;)

  • Mangala Kulasekera

    It is not available ask transmitter receiver and decoder in my country.how can I get these.

  • viju
  • http://www.electrosome.com/ Ligo George

    You can download the entire code at the bottom of above article.. just before the ads..

    If haven’t yet done it with float..

  • http://www.electrosome.com/ Ligo George

    Try online shopping..

  • axel
  • http://www.electrosome.com/ Ligo George

    Download the above zip file and extract it.

  • Batman

    I use a uln2803 because is not available ask transmiter in my country,it doesn’t mather right?

  • http://www.electrosome.com/ Ligo George

    Which Country?

  • Batman

    I need or not the ULN2803?

  • http://www.electrosome.com/ Ligo George

    You don’t need ULN2803 for this project..

  • murthy

    hi, can i use PIC 16F877

  • Murthy kamireddi

    Hi, While programming to IC i am getting some problem, so please help me..

  • http://www.electrosome.com/ Ligo George

    yes, just change the pic in mikroc project settings..

  • http://www.electrosome.com/ Ligo George

    Hello,
    Please elaborate your problem….. I don’t get it..

  • Murthy kamireddi

    hi, While programming to IC i am getting some problem (see in photo attached)

  • http://www.electrosome.com/ Ligo George

    Why did you use Manual Device Select ? PICkit 2 can automatically detect the target. .
    Uncheck Programmer >> Manual Device Select

    Try changing the PIC Microcontroller..

    And the above project is done using PIC 16F877A.. not using PIC 16F877

  • Murthy kamireddi

    ok, i will try, thank you

  • Murthy kamireddi

    I have done this project, its working successfully, thanks for this project

  • Murthy kamireddi

    ……….

  • http://www.electrosome.com/ Ligo George

    Hello,
    Thanks for the feedback. :-)

  • Murthy kamireddi

    Hi, Its not sensing from tank(first floor) to main controller with receiver(in ground floor), if both are in same floor its working, so what should i do.

  • http://www.electrosome.com/ Ligo George

    I think, it is the problem of your antenna… Try using simple wire antenna or Aerial antenna..

  • Murthy kamireddi

    I have used antenna by using Copper wire(shown in attached pic)

  • http://www.electrosome.com/ Ligo George

    Use a simple aerial antenna.. or simple wire antenna.. without these turns..

  • Murthy kamireddi

    While starting LCD display its showing “Project developed by———————–” . Is it possible to change that names in source code.

  • http://www.electrosome.com/ Ligo George

    Yes, it is possible.. You can edit the source code..

  • Murthy kamireddi

    1) what file should i use from above RAR,…….
    ASM or MicroC.
    2) which lines i have to change

    Please give me some instructions.

  • http://www.electrosome.com/ Ligo George

    Download and install mikroC pro for pic microcontroller… open wli.mcppi using that..
    You can find C code there and edit it. .

  • Murthy kamireddi

    Then how to convert that file to hex

  • http://www.electrosome.com/ Ligo George

    Build the code after editing, then the new hex file will be generated.