I have a water pump for Raspberry Pi (https://thepihut.com/products/amphibious-horizontal-submersible-pump) that I want to use.

Do I need a relay module for this water pump to make it work with Raspberry Pi 4 ?

I want to use a soil moisture sensor and depending on the value of the soil moisture sensor I would water the plant ( I will use a database that compares the current value with the value from the database)

Which soil moisturise is best to use and do I need any additional components for that soil moisture sensor to make it work with my Pi 4?

1 Answer 1


do I need relay module for this water pump to make it work with Raspberry Pi?

That might be easiest (??), but all you really need in this case is a bipolar NPN transistor with a resistor and diode for support. The pump current is too much for a GPIO pin alone, and it's probably easier/better to power the pump from the 5V source. See schematic:


simulate this circuit – Schematic created using CircuitLab

Just a few words about the components:

  • R1 sets base drive current to Darlington NPN MPSA29. 330ohms limits base drive to 10 mA which is a safe value for GPIO.

  • 1N5817 is a Schottky diode used as a "snubber" to limit the L * di/dt voltage seen at the collector of Q1 when the PUMP is switched OFF.

  • Q1 is a Darlington NPN transistor (P/N MPSA29) designed to switch a 500mA load safely. The pump specifications claim a max current of 220mA, so this transistor covers that with a reasonable margin of safety. And if you check the spec sheet for the MPSA29, you'll find that it has a Vce,sat that will keep the pump voltage within specifications.

  • The pump is effectively grounded when the transistor switches ON. The switch configuration shown in the schematic is sometimes called a "low side" switch. The alternative is a "high side" switch, but this would require a PNP transistor, and presents challenges in driving from a 5V source.

  • WRT choosing an "old school" bipolar transistor (instead of a MOSFET), I've rendered my opinion on that here on multiple occasions.

  • And speaking of voltages, you should be fine powering the pump from a 5V pin on your RPi's header, though this may be pushing "best practices" a bit as the RPi is rather finicky about its supply voltage.

All these parts should be readily available through distribution (Farnell, Avnet, Mouser, Arrow, etc, etc).

Which soil moisturise is best to use and do I need any additional components for that soil moisture sensor to make it work with my Pi?

I'm not going to help you choose a moisture sensor; the rules here preclude "shopping requests". I will point you to this video explaining which moisture sensors "suck" - and should therefore be avoided. Sources for moisture sensors include many of the same places you're buying your other stuff, or use a search engine with 'capacitive moisture sensors' - or something similar.

As far as the hookup to your Pi goes, that will depend on which sensor you choose. Most vendors will have suggestions - or if you're confused, ask another question here after you choose your sensor.

  • I am not sure, how the connection will be made between the pump and other components. Let me explain: The pump has two wires, one is for the main voltage (3v - 5v) and the other one is ground. In the schematic, shouldn't the ground wire of the pump be connected to the ground?? Another question: Just to make sure, should the pump be connected to one of the 5v pins on the Raspberry Pi 4? or would I need an external supply?
    – Huzzy
    Commented Feb 21 at 15:42
  • I cannot vote up. when I tried last time and this time, I got this prompt "15 reputations needed". I was connecting other hardware such as temp/humidity, soil moisture, ultrasonic sensor. I didn't know the Pi doesn't have ADC pin so I was trying to figure that out. I need up using MAP3008. I got the motor part couple of days ago. Thank you for your time and effort.
    – Huzzy
    Commented Feb 24 at 14:11
  • @Huzzy: You're welcome. Yeah - a rep limit on upvotes, but not on accepting an answer. I see you're pushing 15 rep now, so only 2 more to go before you can upvote. I'm kinda' busy at the moment, but I'll answer your questions in an edit to my answer as soon as I can.
    – Seamus
    Commented Feb 24 at 20:22
  • I have made it work, thanks to you. I connected the gate of my MOSFET BS170 to the GPIO and a resistor (1Kohms), drain across the external supply super and positive terminal of the water pump and finally source to the ground. I connected the other terminal of the water pump to the drain as well. Probably worth mentioning that my motor stayed on or "High" when the GPIO pin was set to "LOW" or when I exited the script, to overcome this issue I added a pulldown resistor(1Kohms). Now it is working as I expected.
    – Huzzy
    Commented Feb 25 at 11:41
  • @Huzzy: Using the MOSFET was a mistake. But - after you've experienced further anomalies, you can "switch" to a bipolar device :)
    – Seamus
    Commented Feb 25 at 16:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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