2

I am trying to control a 5V pump with arduino and ultrasonic sensor however i can't make it work with the pump connected to a pin.

I saw on the forum that you need transistor or relay but i don't understand why ?

Thanks !

2

Probably because the pump will use more current (mA) than a GPIO pin of the Arduino can deliver.

A GPIO pin on the Arduino can deliver 20 mA, or 40 mA max (but not advised for longer time).

Therefore, a separate power supplyis used, where the base pin of a transistor is connected to a GPIO pin (with a resistor) to 'switch' the transistor on and off. The transistor base can be very low current (way within a GPIO's current range), which result in a much bigger current from the collector (connected to the power supply) to the emitter (connected to GND). The pump is somewhere between the external power supply and GND).

If you search for 'transistor as a switch' you will find many examples.

You also can use a relay if you don't need to switch it on often. Relay's are typically used for net-powered devices (110+ volts) and/or high current. See also Duncan's comments for additional notes regarding relays.

| improve this answer | |
  • 2
    Good answer as usual, but if you use a relay the relay's coils will almost certainly need more current than a GPIO pin can provide, so you'll still need a transistor (And a "flyback diode") to drive the relay. There are various "digital relay" modules that have all that built in and are meant to be controlled directly from a 5V GPIO pin. You feed them a 5V supply line, plus the control signal, and they turn the relay on or off based on the digital pin. – Duncan C May 9 at 16:58
  • 2
    Also note that if you drive an inductive load like a pump from a transistor, you should have a "flyback diode" to protect the transistor from back EMF from the inductor. – Duncan C May 9 at 16:59
  • @DuncanC Good comment as usual :-) ... I have to admit for some tests I indeed did not use a 'bare' relay, but a relay module, which contains the flyback diode and opto coupler probably together with a transistor. I added a line in my answer to read your comments. – Michel Keijzers May 9 at 17:00
  • 1
    Thansk for the answers ! i did with transistor and it worked thanks however if i connect the pump straight to the 5v it work so it means that the pin on the arduino have less voltage/ ampere ? – Thomas Sxt May 11 at 16:35
  • 1
    Okok gonna check that ! thanks a lot for your help! – Thomas Sxt May 12 at 8:12
1

@michel-keijzers has pointed you in the right direction. Depending upon the power requirements for your pump, you might consider looking specifically at logic-level power MOSFETs as the type of transistor in your circuit.

You might also investigate the use of a pull-up resistor to fully turn on a MOSFET.

| improve this answer | |
  • MOSFET is actually a tag in this forum (arduino.stackexchange.com/questions/tagged/mosfet). You might get some ideas from other questions. – BalooRM May 9 at 14:28
  • 1
    Indeed, logic level MOSFETs are often an excellent choice because they draw almost no current from the controlling GPIO pin. They have VERY low "on resistance" so they can control high current (DC) loads while generating very little heat and wasting very little power. – Duncan C May 9 at 17:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.