Continue to Site

Welcome to

Welcome to our site! is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

water level control using atmega128

Not open for further replies.


Newbie level 2
Sep 5, 2009
Reaction score
Trophy points
Activity points
water domestic tanks level control

i am using the microcontroller atmega128 and my motive is to control the level of the water in a tank.
Now in my project i have tank A and Tank B. Both are connected to water supply.
Now the flowchart is. first the solenoid valve connected to tank A inlet pipe will be turned on manually then, when water reaches to certain level the solenoid valve should get closed automatically and the solenoid valve for tank B should get turned on automatically. then when tank B is full then the solenoid valve B should get closed automatically.
I am new to C programming so finding it difficult to write a program for this project if some one can help with the program it would be great.

level control using level transducers

Please post your schematics. You`ll need hardware resources to turn on and off the solenoids and to read the water level. Why are you using a tank to kill an ant? Any ATtiny will do the job. What compiler are you using?

chlorine solenoid valve

here is the project report , i hope it helps
thanks for your reply

link for the schematic is:

working of the project

1. First in the given figure, solenoid valve A opens and the tank A filled with water. When tank A is filled, solenoid valve B opens and respectively tank B filled with chlorine. Both the solenoid valves open by the help of a optocoupler
2. Once, both the tanks are filled to a given level, and then we manually start both the submersible water pumps.
3. At this point, both valve A and valve B are open.
4. Both water and chlorine is filled in reservoir C till level reaches let say “ 10 Litres”.
5. When the liquid level reached above the 10 mark, then the pressure transducer will send signal to the microcontroller to close valves A and B
6. We put a conductance probe in reservoir C and we set it to a point say “5”.
7. If the conductance is above “5”, then valve A opens and water is filled in the reservoir C till it matches the set point.
8. If the conductance is below “5”, then valve B opens and chlorine is filled in the reservoir C till it reaches its set point.
9. Let’s assume now that the liquid in reservoir C is 20 litres due to the control actions taking place.
10. If the industry requires a certain amount of liquid let’s say “15” litres from the reservoir, then we set the required set point for the microcontroller.
11. Now pressure transducer is giving a reading of 20 litres to the controller which results in the opening of the valve
12. Valve C closes when the pressure transducer gives a reading which matches the microcontroller set point.

water level controller project

I suppose that the interface circuits were removed from the blockdiagram. If you have them working fine it´s all right.
Now, to controll the system using a C program you need to know where in the microcontroller are the interfaces connected.
Suppose the control of solenoid A is connected to Port B pin 2. Using C, a single instruction like
PORTB.2 = 1; //puts it to logic level 1 = 5V
will turn the solenoid on and
PORTB.2 = 0; //puts it to logic level 0 = 0V
will turn the solenoid off.
The input readings are a little different because they seem to be comming from an analog signal. They can be read using the built-in ADC of the ATmega. Using the ADC you can decide on the water level and actuate the solenoids.
Which compiler are you using?
One more important thing. Are the interfaces opto-isolated, snubbered, etc?

Not open for further replies.

Part and Inventory Search

Welcome to