water tank pump circuit

Smart Water Tank Pump Switcher

For the residents who live in rural-areas, limited water-availability is a very common problem. Therefore, many people install a water tank on the roof of the building. The water, stored in a water tank at the basement (ground) is pumped into the water tank on the roof using a pumping motor. In this manner, the limited water-availability problem can be improved and the water can be used in a more efficient way if an automatic water tank pump controller is included in the setup.

Using traditional for water level controller has the advantages of simple structure and low cost. Traditional water level controller can control the water between two levels with the help of floating balls/float switch as the sensors for level detection. According to the positions of the floating balls/float switch, the electric connection of the pumping motor is set to be on or off. However, the controller unit is usually placed at the top of water tank, humidity may corrode the contact points of the sensor switch. This will cause the sensor switch to mal-function. Meanwhile, since there are no means to detect the water level of the basement water tank, it is possible that the pumping motor will be burned if there is very low/zero water level in the basement water tank.

Since the traditional water level controller has inherent problems, many people prefer digital electronics to detect and control the water level in an intelligent manner. Here is a simple yet effective water tank pump switcher circuit, realized using the renowned AVR microcontroller Atmega328P-PU. The circuit can be used to maintain the level of water in the overhead water tank within prescribed limits.

Automatic Water Tank Pump Switch Hardware

Microcontroller Unit: The designed circuit shown here includes an Atmega328P-PU as the kernel, a number of LEDs to display the system status, a push button switch for auto/manual mode selection,an electromagnetic relay as the driver of the pumping motor, and a few other external components.

The basic design idea is to set two ports of the MCU for water level detection, one port for automatic/manual mode switch selection, and two ports for visual status indication. From the reading of the water level detection ports, the internal software can determine the water level of the overhead water tank. Note that E2PROM storage option of the microcontroller is also used here.

water pump system diagram

Basic System Diagram

Water Level Sensors: The roof (overhead) water tank level sensor is nothing but a (readymade/homemade) reed-switch actuated vertical-mount (2-point level) float switch consists of low and high water level sensors, placed at two different heights in the overhead water tank. The basement water tank level sensor is another simple (1-point level) float switch, added as a dry-run protector. Hermetically sealed-in-glass reed switches located inside the stem are activated/deactivated by the upward/downward movement of the strong magnet in the tailpiece of the float.

Power Supply Unit: The circuit will work with dc supply voltages in the 9 – 12Vrange, and hence any standard 1Ampere-rated dc power adapaters with an output voltage in the range can be used to energize the entire system. An on-board linear voltage regulator is included in the system to provide a clean dc supply to the whole electronics circuitry.

System Description

As stated, to read the water level of the overhead water tank there are two sensors, one for low level (L) and the other for high (H) level. Try to use a magnetic float switch that activates two reed sensors so that the float (with magnet) should terminate its travel in front of L and H reed sensors. If the L sensor triggers its microcontroller input, the water pump is activated. Now the STANDBY indicator LED goes off, and PUMP ON on indicator LED lights up. When H level is reached, ie the H sensor triggers its microcontroller input, water pump is deactivated. Now the PUMP ON indicator goes off, and the STANDBY indicator lights up again. Water pump is reactivated only when water drops back to L level.

Further, in automatic mode, if the (optional) third sensor (dry run sensor) is fitted in the basement water tank, the sensor (G) triggers its microcontroller input to inform the system that there is no water in the basement water tank.
As a result, the system immediately deactivates the water pump to protect the electric motor of the water pump.

Water Level Sensors

Water Level Sensors

The system also features an Auto/Manual operation. In AUTO mode, the water pump stops then maximum water level (H) is reached. In MANUAL mode, water level detection process is overridden and the water pump keeps working endlessly. Simultaneously, MANUAL mode indicator LED lights up as a warning indicator.
The AUTO/MAN mode can be toggled at any water level using the AUTO/MAN push button switch.

Circuit Description

water tank pump circuit

The Atmega328P-PU (IC1) chip in this circuit is infact an Arduino UNO chip, that is to say IC1 holds a small code prepared & processed using Arduino IDE. Switch S1 is the traditional reset switch as found in the Arduino board. Here, ports PD2, PD4 and PD7 of IC1 (D2, D4, D7 of Arduino) are configured as input ports,and ports PB0, PB4 and PB5 (D8, D12, D13 of Arduino) are configured as output ports. PD2 port is connected to the AUTO/MAN mode selector switch. Water level sensors are read by ports PD4 and PD5. Port PB5 is used to conttrol the water pump motor through a heavy-duty electromagnetic relay (RL1) with the help of the driver transistor (T1). Rest of the output ports (PB0 & PB5) are used to drive the system status indicators (LED1 & LED2).

IC1 (ofcourse with pre-loaded Arduino UNO Bootloader) can be programmed/re-programmed through the serial interface socket J3 using a commonly available FTDI Basic board (usb-serial converter board). Water level sensors of the water tank at roof, and water level sensor of the water tank at basement (ground) can be connected to the circuit through sockets J1 and J2 respectively.

Socket J4 is the DC input socket, from where the system is powered by a regulated 5VDC supply, pre-processed by the on-board voltage regulator chip (IC2). LED4 works as the power supply status (on/off) indicator.

FTDI Basic

FTDI Basic

Software Description

From the circuit diagram (hardware), one can find that very few external components are needed. Moreover, one can also find that the software is very easy to be modify if more functions are to be added. This will increase the flexibility and liability of the design. Here is the core logic of the microcontroller, prepared in Arduino IDE:

 *Smart Water Tank Pump Switcher
 *An Arduino-Based Project
 *Designed by T.K.Hareendran
 *Tested @ TechNode PROTOLABZ
 *IDE: Arduino 0022 / Board:Arduino UNO-R3 / Chip: ATmega328P-PU
 *Date: November 14,2014

#include <EEPROM.h>

#define inputLevel1  4  //Tank Level-Low

#define inputLevel2  7  //Tank Level-High
#define modeSwitch   2 //Auto/Manual Mode Switch

#define statLED  8 //System Status Indicator

#define modeLED  12  //Auto/Manual Mode Indicator
#define driveOutput 13 //Water Pump Swicth Output
#define memposL1  0  //Set constant eeprom position 0 to save Level1

int state=0;
int level = 0;
int lastlevel = 0;

void setup (){

  digitalWrite(modeSwitch, HIGH);     
  digitalWrite(inputLevel1, HIGH);    

  digitalWrite(inputLevel2, HIGH);     

  pinMode(driveOutput, OUTPUT);
  pinMode(statLED, OUTPUT);
  pinMode(modeLED, OUTPUT);

  level =; 
  lastlevel = level;           
  if ((level == 0)||(level>2)) { 

void visualdrive() {

  digitalWrite(statLED, LOW );

  if (level >1)   digitalWrite(statLED, HIGH );


void  pumpdrive(){ 
  if (level < 2)   digitalWrite(driveOutput, HIGH );
  if ((level == 2) & (state == 0)) {
    digitalWrite(driveOutput, LOW );
  else {
    digitalWrite(driveOutput, HIGH );

void refreshmem() {

  lastlevel = level;      
  EEPROM.write(memposL1, level);   

void loop () {
  if ( (digitalRead(modeSwitch) == LOW) & (state == 0) ) { 
    digitalWrite(modeLED, state );        

  if ( (digitalRead(modeSwitch) == LOW) & (state == 1)  ) { 
    digitalWrite(modeLED, state );       

  if ( digitalRead(inputLevel1) == LOW  ) { 
    level = 1;

  if ( digitalRead(inputLevel2) == LOW  ) { 
    level = 2;

  if (level != lastlevel) {

Suggested component layout for a double-sided pcb

Suggested component layout for a double-sided pcb

The microcontroller on the Arduino board has EEPROM (E2PROM) memory whose values are kept when the board is turned off. The EEPROM library enables you to read and write those bytes. The Atmega328 microcontroller have an amount of 1024 bytes.


Join the conversation!

Error! Please fill all fields.
  • Jack

    I love these types of projects. They are fun to build, educational (even to the professional) and serve a purpose that you can be proud of for years. As a retired programmer/hardware person, I do have a couple of suggestions.

    1) there appears to be no time requirements here, so remove the crystal and associated caps. I have a number of home projects that use the 328p and they run on their internal 8 MHz calibrated oscillator. Divided by 8 (default 328p) for a 1 MIPS operation (instead of 16 MIPS.) Plenty fast for this type of operation. (tip, a slower clock will allow a lower Vcc for power or voltage considerations)

    2) generally when you have inputs, the hardware should ensure a stable state, using pull up or down resistors. It’s an easy solution with the 328p, just turn on the pull up resistors on the devices inputs. On the Arduino IDE the input coded as “pinMode(6, INPUT_PULLUP)” to enable them. I use this to interface for switches where it just pulls it to ground. These ‘modes’ such as INPUT as defined in Arduino.h header files.

    3) from the software end of things I see people code comparisons, like yours. This is a habit that is easily broken when you find it catches typo bugs in your code.

    Code (works) Common typo Compiler results
    (state == 1) (state = 1) OK, but bug in code
    (1 == state) (1 = state) Error, compiler catches it

    As a retired programmer and teacher, I’ve seen countless bugs induced by typo’s like this.

    For those that wish to take it to steps like this, I suggest start reading the technical literature from Atmel. I know it’s like legalese, but it has some programming examples and details how to program for items like the pull up resistors. The more you read them the better you get.

    This also lowers the component count on the board, when you know the device better. I have a couple that have a voltage regulator, a power mosfet and a switch. The complete item has 5 parts or less. I’m switching 15 amps on one of them. Internal oscillator of course. Best of all have fun.

    Nice project, wish I’d seen it earlier… Take care.


    • T.K.Hareendran

      Thank you for your keen interest in my project, and your constructive suggestions.
      I would love to hear from you regarding your experiences with this project, or another project similar to this one. Good Day!

  • sat

    This project looks nice, I have a request is it possible to make ON an another pin while motor ON and keep delay and off after delay?

  • Dr D. K. Ghosh

    I like the auto system for our housing society.

    Wish to have supplier with installation , cost and guarantee if any.

  • yigrem

    continue as such improve techenology

  • P.A.Somasiri

    Dear sir i build this water level controller circuit. I have some Problem. When the pump put on standby mode the led will blink this is ok . But the same time the pump also on and off continuouslly.Please give me instructions Thanks.

  • K rajeswararao

    Sir, We need training,
    Start new business.


  • Marion

    Very good and neat.

  • Martin

    Excellent article. Thanks! Quick question though: what would be the ballpark cost of a typical setup as described here? Cheers.

  • Rene Stover

    This is a great project, which as I see, can be adapted to many other applications, with just a little code and hardware changes. Thanks!

Looking for the latest from TI?