Pump with a MOSFET

Posted on 2019-12-15

Setting up the pump with a MOSFET switch.

MOSFETs

Mosfet stands for metal-oxide-semiconductor field-effect transistor. It is effectively a switch activated by an electrical source of lower volt/amps than that needed to power a device.

I am using an FQP30N06L: 60V LOGIC N-Channel MOSFET. The datasheet is here. N-channel means that the gate terminal must increase voltage to close the circuit, and so let the light switch on or equivalent, as opposed to a P-channel where increasing the voltage opens the circuit.

The three pins, left to right when facing the markings, are

  • Gate
  • Drain
  • Source

The pump

It’s a submersible pump that runs on 5V. It’s unbranded and has no markings of any kind, but looks identical to the generic result when searching for “Mini Submersible Water Pump”.

[Note from the future: these don’t last very long.]

Wiring

The schematic for an N-channel MOSFET

mosfet-pump-schematic

I followed the diagram I found here.

  • To the gate pin, I connect to a GPIO pin, as well as proving a 10k ohm resistor to ground. This stops “floating” voltage causing unintended on signals.
  • The drain is connected to the ground of the pump.
  • The source is connected to the ground on the pi.
  • The 5V pin on the pi is then connected to the pump.

Checking: Using the jumper from the gate of the MOSFET to contact the 3.3V output, instead of a GPIO pin, kicks the pump off. Disconnecting it sees the pump switch off - thanks to the grounding of the gate.

Software

A quick demo script

import time 
import RPi.GPIO as gpio

gpio.setmode(gpio.BOARD)


def signal_on_time(pin, time):
    gpio.output(pin, 1) 
    time.sleep(time)
    gpio.output(pin, 0)
 
PUMP_PIN = 27
UP_TIME = 1

gpio.setup(PUMP_PIN, gpio.OUT)
signal_on_time(PUMP_PIN, UP_TIME)