Raspberry Pi + MOSFET = High power switch

With all the possibilities, Raspberry Pi requires additional hardware to turn on and off any additional hardware. GPIOs built in power limit is low: 3.3V, 16mA per GPIO, but not more that 50mA total). And while it might be enough to light a small LED, it is not enough for anything else. Forget about motors, strong LEDs, relays. Anything that uses more that 16mA on input will destroy Raspberry Pi.

Luckily, there are things called MOSFET. To keep things short: they are special kind of transistors that can be used to turn on and off devices with high power requirements. Unfortunately, most MOSFETs require more that 3.3V Raspberry Pi GPIO provides. So you either have to use 3.3V logic compatible MOSFETs or add few other elements and use more common 5V compatible MOSFET like 30N06. And 30N06 MOSFET transistor can handle a lot of thing: up to 30A and 60V. So it’s more that enough to handle most 12V motors, relays, lights, LEDs, etc.

30N06 MOSFET Raspberry Pi


Required elements:

  • NPN BC547 (or compatible) transistor,
  • PNP BC640 (or compatible) transistor,
  • 30N06 MOSFET transistor,
  • 3x 10kOhm resistors,
  • 4.7kOhm resistors,
  • 1N4001 (or similar) diode

If it was Arduino with 5V logic, transistors would not be required. But with Raspberry Pi’s 3.3V logic they are required to bump voltage from 3.3V GPIO port provides to 5V MOSFET needs. Additionally, if we would be powering any coil device (motor, relay), flyback diode would be required to secure MOSFET from voltage spikes. Even if there is no coil, flyback diode still can be used. Just to be safe.

8 thoughts to “Raspberry Pi + MOSFET = High power switch”

    1. In this case, 3.3V of GPIO is not enough to fully open MOSFET. We have to boost it to 5V. Also, in this case, bipolar transistors acts like a inverter

      1. I am also curious as to the two transistors. Could I also create the circuit where +5 is connected to the Collector of the 547 and then the Emitter is fed into the gate? I could still pulldown the GOIP to ground and limit the current into the 547 making it a single transistor switch. What is the benefit of inverting in this case (I’m guessing there is some kind of benefit but I am not sure what it might be).

  1. works nicely! Thank your very much for the description.
    I was wondering why there is such a high resistor (4.7kOhm) bewtween the GPIO and the NPN transistor.
    Shouldn’t that be lower to ensure fast switching of the NPN in case a high frequencecy PWM is wanted?

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.