Go Down

Topic: 5-12v Water Pump control problems (Read 19126 times) previous topic - next topic


Hello everyone!

I have recently received the stater kit from Adafruit and started tinkering with the Arduino :

For my "HydroDuino" (automated hydroponics using the arduino) project
-i am currently trying to control a 5-12V water pump (basic on /off ) using one digital pin
-i need very precise timing in order to avoid overflow : this part works very well (tested with a simple led)
-i am not really good at electronics but after looking around i decided to go with a tip 120 transistor (with a diode for security) (schematics found here http://ctheds.wordpress.com/2007/10/30/tip-120/for example

More info etc in my blog http://www.kaosat.net/?tag=hydroduino

   * i am having HUGE speed fluctuations in the pump, so each and every time i start the system, i get different speeds, which pretty much defeats the whole "precise timing for a precise filling".

   *o in a lot of cases the motor starts of veeery slowly, and the speedup rate to an acceptable level always varies
      o sometimes about halfway through the timing interval (set at 180 seconds for now), i will get a sudden decrease in power : my guess is this is tied to the tip120 transistor, and the lack of sufficient "differential" :  i managed to reduce this problem somewhat by exchanging the 1k transistor that goes to the base from the Arduino digital pin with a lower rated resistor

   * these problems are unlikely to come directly from the pump as i did not have such fluctuation when running it directly on the power supply

   * i am also aware that using a cheap 8$ pump which eats up 2.2A at 5v (twice what was indicated on the seller's site) is also begging for problems

   * I am not really good at electronics, but from what i gathered, i might need to add a few capacitors to smooth out the current and reduce the spikes?. like here ? http://www.tigoe.net/pcomp/code/category/Picbasic%20Pro/62

Sorry for my obvious lack of mastery in this field, but i am more than willing to learn :)

Any help , comment or suggestions is appreciated!
Thanks in advance


Mar 20, 2009, 04:07 pm Last Edit: Mar 20, 2009, 04:09 pm by Grumpy_Mike Reason: 1
i might need to add a few capacitors to smooth out the current and reduce the spikes


cheap 8$ pump which eats up 2.2A at 5v

Was it specified to run at 5V? If you are running it at a lower voltage you might get excessive current because of the nature of an inductive load.

by exchanging the 1k transistor that goes to the base from the Arduino digital pin with a lower rated resistor

You actually mean low value resistor, a lower rated one refers to the power dissipation capability. That being said what value did you use? A TIP120 does not have too higher gain, you could try adding an other small signal transistor to make up a Darlington pair (Goggle it). The other thing you could consider is using a MOSFET in place of a transistor. These tend to switch on harder. You could also use a relay to get a better hard switch.

i am having HUGE speed fluctuations in the pump,

Basically you are implementing an open loop system. That is, there is no feedback, so there are fluctuations like this. To make a closed loop system you would have to monitor how much water you pump wit a flow meter, forget the timing and pump until you have pumped enough water.


Mar 20, 2009, 04:59 pm Last Edit: Mar 20, 2009, 05:00 pm by RIDDICK Reason: 1
hey yo!

u could put 2 cables into the tank and connect each cable to a high resistor (1MOhm or so) and connect one cable to arduino's GND and the other to an analog input, that is pulled up to arduino's 5V via a 10MOhm resistor...

in case of a little error the current would be quite low (5V / (2MOhm) = 2.5uA)...
in normal operation mode u would have an even lower current (5V / (12MOhm) = 417nA)...
maybe that current would damage the electrodes over the time and poison the water?  :-?

or u use an empty (just filled with air) bottle, that pushes against a button, when it is lifted by the rising water...  :)



what RIDDICK is suggesting is a homemade float switch. Search around and you will find plenty off the shelf items.

If you want to have full control over the pump then i suggest a PID controller. Have a look here for more details: http://www.arduino.cc/playground/Code/PIDLibrary

In order to use a PID controller though you will need to calculate error, for which you will need a measure of the amount of fluid in a tank. Essentially you need a sensor which will report the level of fluid in the tank. As the level rises closer and closer to the setpoint, the PID controller begins to decrease output to the pump, thereby slowing it down, until it finally reaches the setpoint.

If you post more details about the scenario, you will get better responses. The above assumes the pump is pumping water into a tank, but I'm pretty sure that is incorrect. If that isn't the case, then you need to use a flow meter instead, which will report the rate of flow. By monitoring the rate of flow and elapsed time, you will have a clear indication as to the volume of liquid which has been pumped. In this case, you can use the PID controller to control the motor with respect to the flow meter.


Wow, thank you all for the very quick replies!

I guess i really wasn't clear enough about the project itself:
-This will control the water flow in a homemade ebb & flow irrigation system: basically the water is being pushed up through the BOTTOM of the bottles at set intervals per day.
-Once the set level in the bottles have been reached , the pump shuts of and releases the water BACK into the container.

more on it here :http://www.hhydro.com/cgi-bin/hhydro/ebbFAQ.html

-some picture for more clarity (on these photos i only linked up two bottles but normally it's four)

bigger versions just in case :


-thanks for that link, i have read it but i will do so a couple more time to understand all the concepts:)
-well i am running it at a lower voltage : normally it is a 6-12v pump, but i tried it at 12v and not only is it way too fast , but it also almost fried the tip120
-to get the Amperage i measure the resistance of the motor (when not running it is about 2.2 ohms), and then i divide the actual voltage used by the resistance
-yes sorry about that it is a lower valued resistor :100 ohms
-i will take a look at the Darlington pair thanks for that :)
-i am not really sure what way i would have to measure the water flow, as the tubings are 1/4" ...hmm although, now that i think of it i could perhaps calculate the flow based on the elapsed time between two set level of water..i will study this !

RIDDICK & FusiveResonance
-you are both quite right, that is indeed a possible solution
-given the requirement in the system i think i would need to add one such electrode per bottle and use any kind of "logical OR" operation to gather the input of all the bottle and switch the pump off if the water in ANY  of the containers reaches a critical level
-i don't really know if there would be a danger of running 5v though the water but i doubt it , if i remember right i have seen EC meters with way higher voltage
-actually i even think i might be able to use this electrode system to both measure the water level AND monitor the electrical conductivity of the water ...then again, if the resistance of the water changes...hmm
-the float switch would unfortunately be very impractical in this case (see pics)
-wow, didn't know about the PID controller, but i'll definitely have a use for it, since i will need to monitor and control a lot of other parameters thanks:)


i have new idea after i saw the bottles:
u could use 2 light dependant resistors (LDR): one at the critical level and the other right above it...
when the difference is high, it is hopefully not a shadow, but the rising water... :-)


If the TIP120 transistor is getting too hot, that may be because it is not fully switched "on".  A transistor that is fully "on" is said to be "saturated", and has a low collector-to-emitter voltage (less than a volt, maybe as low as 0.2V).  Could you measure the voltage across C and E of the TIP120, when the pump is on?  A transistor needs a certain amount of base current to get it into saturation, so one way would be to reduce the value (Ohms) of the base resistor.


Mar 20, 2009, 10:07 pm Last Edit: Mar 20, 2009, 10:07 pm by weirdo557 Reason: 1
why not avoid all the saturation problems and just use a logic level mosfet? (edit: oops, already suggested)


The TIP120 is a darlington pair with a minimum gain of 1000 and a max base current of 120 mA per this data sheet:


So you should be able to saturate it with a 125-250 ohm resistor between the Arduino and the base of the TIP120.  At 220 ohms, you'll deliver about 23mA to the base, which will give you up to around 2A of available drive current to the pump motor.  (150 ohms -> 33mA and just over 3A drive current) Don't go below 125 ohms or you risk overloading the pin on the Arduino.  To saturate a transistor means to provide more current to the base than necessary in order to fully switch the transistor 'on'.  This allows the least voltage drop across the collector and emitter, freeing up that voltage for your load (the pumps).

If you're still not getting a consistent speed, you may need to run the motor closer to its rated voltage and/or use a power supply that provides more current.  Motors draw more current when they start up, especially when they are loaded down.  In the case of a pump, load is present as long as there is water in the pump.  So it's going to draw a big surge of current right as it's first powered on.  My bet is that you don't have a strong enough power supply for the motors.  It may also be that the current draw of the pumps at start up is high enough to take the transistor out of saturation mode, which will cause it to eat voltage, heat up and slow the pump down.

To be sure, post the current rating (amps) or wattage rating of the pumps and one of us can verify for you.

Ran Talbott

The TIP120 is a Darlington:  looking at the datasheet,  it would be dissipating about 2W if it were sinking 2.2A.  Not enough to fry it,  but it would probably be happier if it had some help from a heatsink.




have a look here for an idea of a float switch: http://www.meder.com/levelsensor_ls02.html?&tx_jppageteaser_pi1[backId]=2952

The picture isn't oriented properly, but imagine that the assembly suspended inside your tank with the cable going up and out. Now, as the liquid level rises, it will contact the float and will cause it to also rise. As soon as the float hits the contact surface, it will close the circuit. This assembly is waterproof obviously.

I don't understand why you're saying that this is impractical. Please explain.

This float switch is around $8 to $12. Search for the LS02 series.

Another approach:
Take a piece of plastic (like a disposable plate) and cut it so that it will fit into the tank. You can see that this platform will raise and lower accordingly with the water level.  

Now you have a multitude of options:
1. Affix a magnet onto the platform and mount a hall effect sensor at the top of the tank.

2. Use a distance sensor like this http://ca.mouser.com/Search/ProductDetail.aspx?qs=bgJ5QXnU1LQUhMyYtOJQMQ%3d%3d. The sensor is mounted at the top of tank (so as to keep away from liquids) and measures the distance between it and the platform. (Use an opaque platform)

Now that I understand the situation better, might I suggest disregarding a PID controller. Might as well keep things simple: Run the pump at low speed, and simply stop it when the preset distance is reached.


Mar 21, 2009, 10:00 pm Last Edit: Mar 21, 2009, 10:12 pm by koyaanisqatsi Reason: 1
I don't mean to undermine folks assistance, but after reading a little on the link you provided and studying your pictures, I don't think you need to sense the water level at all.  Since each jar is its own space, which is open on the top, and you only have one pump, flow and level sensing won't be very accurate.  If you had a pump for each jar, you could do that.  What you need is an overflow drain at the top of each of your jars that will allow extra solution to drain away if a jar fills before the others.  The overflow drains should flow faster than the pump can fill the jars.  Depending on how powerful the pump is, you might start at about twice the ID of the fill hoses.  So if the fill hoses were 1/4" ID, then the drain hoses would be 1/2" ID.  You'll need to experiment to find the best size.

Then you only need to work out the timing between fills and how long to run the pump each time.

EDIT: Actually a float won't work even if you did have separate pumps because the growing medium would not provide any free water volume to float on.



The method you suggest is simple, hence elegant. I like it, but have only one concern, but this might not be of much concern to the OP.

There is no feedback being received from your system. You're assuming that the pump will always work perfectly, and that the water will always flow. What if the water supply is shut off? The pumps will turn on for their predefined period of time, and then turn off. The system will continue to run without faulting. Sensors allow for a more intelligent system which can have error detection.


Good point!  Probably ought to have sensors to detect when the reservoir is low and maybe even leakage or spill detection too.

So how about something like this - because I do think having overflow drains will be necessary in any case: put liquid detection in each of the overflow drains.  Poke a couple stainless steel wires into each drain tube and when they all sense flow, then the pump can be shut off.  That way you can handle the likely scenario of the jars not filling at the same speed and avoid overflowing some and under filling others.  You could track the time it takes to fill them each cycle and monitor the health of the pump or identify really bad differences in fill rates between the jars (in case of a clog, maybe).


Yeah, PID wouldn't work since you need to vary the pump speed.  You might want to try using the transistor to turn on a relay, and letting the relay drive the pump motor.  Relays are either on or off, and as long as you have enough current through the transistor to switch the relay, you won't have any weird issues.  You can also use a higher voltage (like 6 or 8) on your pump so you're not under-driving it.  You still need the protection diode on the relay though.

Go Up