Aquarium Auto Refill With Arduino




About: The RobotGeek team is a 6-man operation that wants to make it even easier to use Arduino to make electronics and robots. Check out our instructables and for all of our awesome kits.

This Arduino Pump Tutorial shows a simple example of how to use a float switch and RobotGeek Pumping Station to refill a reservoir once the level gets too low. For our example we use a small aquarium, but this same project could be used for pet dishes, water fountains, or any other number of similar applications. The Pumping Station is a RobotGeek kit which packages a small liquid pump and relay. To operate a pump using an Arduino microcontroller you need a relay to switch on and off a separate power supply.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Project Parts List

Step 2: Wiring

Device Sensor Shield Port
Float Switch Digital Pin 2
One wire to signal / one wire to ground
Pumping Station Digital Pin 4
RobotGeek LED Board Digital Pin 7

Step 3: Load Your Code Onto the Arduino

You can download the code sketch here:

 * Aquarium Pump Refil Demo
 *                       _______________
 *                      |  ___________  |
 * _____________________| |____       | |
 * |  U       <><             |       | |
 * |                          |       | |
 * | ><>          <><         |      _|_|_
 * |   <><                    |      |   |
 * |__________________________|      |___|
 *  This demo will show you how to control a RobotGeek Pumping Station (or any other
 *  motor/pump via relay) based on input from a float switch. This will allow you to
 *  build an automated Aqurium refil pump, refilling your aquarium whenever it gets 
 *  to low.
 *  Wiring
 *  Pin 2 - Float Switch
 *  Pin 4 - RobotGeek Pushbutton relay/pumping station 1
 *  Pin 7 - RobotGeek LED 
 *  Control Behavior:
 *    If the float switch is not floating (i.e. empty tank) then turn on the pump and led
 *    If the float switch is floating (i.e. full tank) turn off the pump and LED
 *  External Resources
//define the input/output pins
#define PUMP_1_PIN 4
#define LED_PIN 7

//setup runs once
void setup()
  //setup input pins for float switch 
  //Too use a bare switch with no external pullup resistor, set the pin mode to INPUT_PULLUP to use internal pull resistors. This will invert the standard high/low behavior
  //setup output pins for relays/pumping station and LED board
  pinMode(PUMP_1_PIN, OUTPUT);
  pinMode(LED_PIN, OUTPUT);

//loop() runs indefinitely 
void loop()
  //check to see the state of the float switch. These states are assuming the pin is using an internal pullup resistor. 
  // LOW corresdponds to the float switch being at its lowest point (i.e. low water)
  if(digitalRead(FLOAT_SWITCH_PIN) == LOW)
     digitalWrite(PUMP_1_PIN, HIGH); //turn on the pump
     digitalWrite(LED_PIN, HIGH);    //turn on the LED
  //otherwise the float switch is HIGH
  // HIGH corresponds to the float switch being at its higest point (i.e. full water)
     digitalWrite(PUMP_1_PIN, LOW); //turn off the pump
     digitalWrite(LED_PIN, LOW);    //turn off the LED

Step 4: Build

Hook up your pump, running the input line to your reservoir and your output line to the tank you wish to fill.

Attach your float switch to the fish tank so that the cylinder floats at the level you want the water.

Place your reservoir at a lower level than your pump. We do this because the pumping station utilizes a diaphragm pump, which will drip water if gravity allows it to flow into the pump.

Step 5: You're Done!

So what's next? You could add a water sensor above the float switch as an overflow emergency shutoff. You could automatically refill your pet's water dish, or use it to make a fountain. You could make a punch bowl that never goes dry for a party. Can you think of a way to use this to water plants? What other things do you know of that would benefit from having a steady water level? Get creative and let us know!

Be the First to Share


    • Made with Math Contest

      Made with Math Contest
    • Multi-Discipline Contest

      Multi-Discipline Contest
    • Robotics Contest

      Robotics Contest

    10 Discussions


    1 year ago

    Interesting instructable. I will pass it on to a friend who understands these things, and makes me one for my aquarium. Thank you so much for sharing.


    3 years ago

    What type hysteresis are you using or programs for this setup? What I mean is if the level switch uses the actual water level to turn on and off, there has to be a point where it would come on fill and turn off but any little ripple would turn it on and off quickly if there is no hysteresis to separate those two on off points. I've built water level sensor circuits myself and they can get into that fine level issue of off and on pretty easily. Just wondering. Nice project though.

    1 reply

    Reply 3 years ago

    It could turn on and off with a ripple, but the physical qualities of the switch have prevented this from happening thus far. It's a digital sensor, so we're not really doing any sampling.That would be a great way to improve upon the project, though!


    3 years ago

    Nice project. I did a multiple plant watering system using a 12 v surplus windshield washer pump, a bunch of small solenoid valves, and of course arduino. Each plant gets water on its own schedule and customized per plant volumes of water. Arduino's rock.

    1 reply

    Reply 3 years ago

    That sounds AWESOME. You should totally put that up on instructables! We've been puttering around with the idea of making a hydroponic/aquaponic system for a while over here. Arduino is great, and everyone would benefit from learning at least a little bit of physical computing.


    3 years ago

    Looks fantastic. The pumping station is a bit pricy for something a cheap pump can do as well, but it surely is neat solution

    2 replies

    Reply 3 years ago

    The price is a bit higher than cheap pumps mainly because our pumps go through some pretty rigorous quality control. If we could do it cheaper while maintaining our quality standard, we totally would. Thank you!


    3 years ago

    How to deal with vaporation of your reservoir? Thinking of adding a pump there ;p

    1 reply

    Reply 3 years ago

    A well sealed reservoir will take quite a while to evaporate, but I suppose an infinite string of pumps would handle the problem just fine. :P