View Full Version : water level controller

01-12-2008, 09:05 PM
guys i wanted to use my mega16 in sleep mode.so i got an idea of making a water tank level controller.
in this i am using two level indications.one at the top and one at the bottom.
the transition from high to low signal on the lower level indicator (no water at bottom to conduct signal) generates an interrupt through INT0.
through the corresponding isr it turns on the bit controlling the pump

the transition from low to high on the high level indicator(tank full) generates an interrupt through INT1 .through the corresponding isr it turns off the bit controlling the pump.

1)But the problem here is I am not sure whether wen no water is present at a particular pin(floating).will it indicate a zero to my avr or not.

2)and also the avrstudio isn't simulating it properly.it stops in between.
3)is the sleep command that i have added valid?

//overhead tank water level controller
//d2 output for relay to the pump
//INT0 low level interrupt
//INT1 high level interrupt


PORTD|=(1<<0); //make pin high


PORTD &=~(1<<0); //make pin low


int main(void)


MCUCR|=(1<<SE); //enabling sleep mode

MCUCR|=(1<<SM0) | (1<<SM1) | (1<<SM2); //selecting idle mode

MCUCR|=(1<<ISC01); //falling edge interrupt sense on INT0

MCUCR|=(1<<ISC11)|(1<<ISC10); //rising edge interrupt sense on INT1

GICR|=(1<<INT0)|(1<<INT1); //interrupt enable

sei(); //enable global interrupt

for( ;;)
void sleep();


please dont blame me for this
does anyone know why the avrfreaks.net site is down since yesterday? :?

01-13-2008, 10:13 AM
sorry not related to ur question but,

i was also planning to build one level controller and indicator for my overhead tank.i did some search and found this circuit.

i liked it bcz,it has both manual and auto modes.but the only problem is with the sensors.i don' recommend placing metallic probes for detecting water level.they will corrode.so planning for some fool proof system.

01-13-2008, 02:40 PM
Firoz, the corrosion happens because of electrolysis. Water in tanks will be an ionic conductor. The two probes that you would dip into the water will act as electrodes.

What you can do is apply an AC signal (at say, 12V) to one of the electrodes, while using the other electrode to detect the signal. This way the electrolysis is vastly reduced. Frequency of the signal should be about 1kHz or more, for this scheme to prevent corrosion. A square waveform generator can be made by a simple op-amp, a ceramic capacitor and some resistances. Of course, you'll need a dual supply for the generator to alternate between + and -. Ask me if you have further questions.

There are other schemes for liquid level detection that use capacitance change between the electrodes (water acts as the dielectric). You could check these as well.

01-13-2008, 11:37 PM
thanks for the explanation.
i had some more ideas in my mind like read relay sensor,using some sort of floating magnet method in side a PVC pipe.i still have to work on it.