Sparky the Blue Smoke Monster shows up whenever the magic smoke is let of of an electronic component. And his very favorite is whenever folks first start with electronics and robotics: wiring up a motor or solenoid or high power LED is a perfect recipe for getting that blue smoke out of an Arduino or Raspberry Pi. Why?

Because these high-current devices can't be connected directly to a GPIO pin on a microcontroller! They need to have a transistor / MOSFET driver, plus a kickback-protection diode that will absorb the inductive 'kick' caused by turning on-and-off motors and solenoids. Without that driver and diode - your 'tronix will go poof!

We have tutorials on how to wire up the components to create a transistor driver on a breadboard, but its easy to put the diode in backwards, or pick the wrong kind of transistor. And some folks don't want to have the extra breadboard for just controlling a simple motor fan or solenoid. Which is why we designed the Adafruit STEMMA MOSFET Driver for Motors, Solenoids, and LEDs.

This board has a simple plug-and-play JST PH (2mm pitch) input connector for solderless use. Provide power (from 3V up to 30V) and signal (3V to 20V logic level). On the output are two-output terminal blocks, with one block connected to power and the other switched to ground when the signal level is high. In between is an AO3406 N-Channel MOSFET rated for 30Vds, 3.6A peak, and 70mΩ RdsOn plus a 1N4007 flyback diode.

You can also get to all the signal and power pins on a 0.1" breakout header if desired, but we expect most folks will like using it as a solderless MOSFET-buddy. Great for driving motors, inductors, high power LEDs, single-color LED strips, or other loads up with to 1.5 Amps continuous draw, 3 Amp peak. Note that the JST PH connector itself is only rated for 2 Amp continuous.

Power Pins

  • V+ - this is the power pin. It is rated for 3V to 30V. You can use a voltage much higher than the signal voltage - so even if you are using a 3V microcontroller, this pin can get up to 30V power.
  • GND - common ground for power and logic.

Input Pin

  • In - this is the signal input pin. When the pin is high, the Output pin is triggered and switched to ground. The signal can be between 2.5V and 20V

Output Pin

  • Out - this is the signal output pin. It can be used for driving motors, inductors, high power LEDs, single-color LED strips, or other loads up with to 1.5 Amps continuous draw, 3 Amp peak. It is switched to ground when the In pin is high. 
Note that the JST PH connector is only rated for 2 Amps continuous.

STEMMA JST PH

  • STEMMA JST PH - 2mm pitch STEMMA JST port with connections for V+, GND and In. Plug in a 3-pin STEMMA JST PH cable with headers or alligator clips on the end and you can easily wire this board up without any soldering at all. Note that the JST PH connector is only rated for 2 Amps continuous.

Output Terminal Blocks

  • Terminal Blocks - two terminal blocks are located on the front of the board for the output. One block is connected to power, labeled +, and the other, labeled -, is connected to Out and is switched to ground when the In pin is high. 

Signal LED and LED Jumper

  • Signal LED - In the lower left corner, below the STEMMA connector, on the front of the board, is the signal LED, labeled Sig. It is the red LED. The Signal LED lights up to let you know when the load is being triggered.
  • Signal LED jumper - This jumper is located on the back of the board directly above the GND pin and is labeled Sig. Cut the trace on this jumper to cut power to the "Sig" LED.

Power LED and LED Jumper

  • Power LED - In the upper left corner, above the STEMMA connector, on the front of the board, is the power LED, labeled ON. It is the green LED.
  • Power LED jumper - This jumper is located on the back of the board directly behind the JST-PH In pin and is labeled On. Cut the trace on this jumper to cut power to the "on" LED.
driver

The terminal blocks on the MOSFET Driver board have latches that need to be pressed in order to properly insert the cables from a load, such as a motor or LED.

With your fingernail or a small flathead screwdriver, press down on the latch of the terminal block. With the latch pressed down, insert the wire from the load.

After inserting the wires they'll be securely plugged into the terminal blocks. If you pull on the wires, they should not move.

To remove the wires, press down on the latch on the terminal block. With the latch depressed, you'll be able to pull the wire out.

It's easy to use the MOSFET Driver with Python or CircuitPython. You can use this breakout with any CircuitPython microcontroller board or with a computer that has GPIO and Python thanks to Adafruit_Blinka, our CircuitPython-for-Python compatibility library.

CircuitPython Microcontroller Wiring

First, wire up a MOSFET driver to your board and attaching a motor to the MOSFET driver terminal blocks, as described on the Plugging into the Terminal Block page, exactly as shown below. Here's an example of wiring a Feather M4 to the MOSFET driver using one of the handy STEMMA JST PH cables:

DC Toy Hobby Motor
These are standard '130 size' DC hobby motors. They come with a wider operating range than most toy motors: from 4.5 to 9VDC instead of 1.5-4.5V. This range makes them perfect...
$1.95
In Stock
If the load that you are driving requires more than 3V, then it will not trigger with this circuit.
  • Board 3V to driver V+ (red wire)
  • Board GND to driver GND (black wire)
  • Board pin 5 to driver In (white wire)
  • Motor black wire to driver terminal block -
  • Motor red wire to driver terminal block +

You can also use standard 0.100" pitch headers to wire it up on a breadboard:

  • Board 3V to driver V+ (red wire)
  • Board GND to driver GND (black wire)
  • Board pin 5 to driver In (white wire)
  • Motor black wire to driver terminal block -
  • Motor red wire to driver terminal block +

Python Computer Wiring

Since there's dozens of Linux computers/boards you can use, below shows wiring for Raspberry Pi. For other platforms, please visit the guide for CircuitPython on Linux to see whether your platform is supported.

Here's the Raspberry Pi wired to the MOSFET driver with a motor and a STEMMA JST PH cable:

  • Pi 3V to driver V+ (red wire)
  • Pi GND to driver GND (black wire)
  • Pi GPIO #5 to driver In (white wire)
  • Motor black wire to driver terminal block -
  • Motor red wire to driver terminal block +

Finally here is an example of how to wire up a Raspberry Pi to the MOSFET driver with a motor using a solderless breadboard:

  • Pi 3V to driver V+ (red wire)
  • Pi GND to driver GND (black wire)
  • Pi GPIO #5 to driver In (white wire)
  • Motor black wire to driver terminal block -
  • Motor red wire to driver terminal block +

Python Installation

You'll need to install the Adafruit_Blinka library that provides the CircuitPython support in Python. This may also require enabling I2C on your platform and verifying you are running Python 3. Since each platform is a little different, and Linux changes often, please visit the CircuitPython on Linux guide to get your computer ready!

CircuitPython Usage

To use with CircuitPython, you need to update code.py with the example script.

Thankfully, this can be done in one go. In the example below, click the Download Project Bundle button below to download the necessary libraries and the code.py file in a zip file. Extract the contents of the zip file, and copy the code.py file to your CIRCUITPY drive.

CIRCUITPY

Python Usage

Once you have the library pip3 installed on your computer, copy or download the following example to your computer, and run the following, replacing code.py with whatever you named the file:

python3 code.py

Example Code

# SPDX-FileCopyrightText: 2022 Liz Clark for Adafruit Industries
#
# SPDX-License-Identifier: MIT

import time
import board
from digitalio import DigitalInOut, Direction

# motor output
solenoid = DigitalInOut(board.D5)
solenoid.direction = Direction.OUTPUT

while True:
    solenoid.value = False
    print("The motor is not triggered.")
    time.sleep(1)
    solenoid.value = True
    print("The motor is triggered.")
    time.sleep(1)

If running CircuitPython: Once everything is saved to the CIRCUITPY drive, connect to the serial console to see the data printed out!

If running Python: The console output will appear wherever you are running Python.

In the example, the pin connected to the breakout is set as an output. Then, in the loop, the pin is turned True and False, toggling the load on and off. In the REPL, the load's status is printed. You'll also see the connected load trigger off and on.

Using the MOSFET driver with Arduino involves wiring up the MOSFET driver to your Arduino-compatible microcontroller and running the provided example code.

Wiring

Wire as shown for a 5V board like an Uno. If you are using a 3V board, like an Adafruit Feather, wire the board's 3V pin to the MOSFET driver V+.

Here is an Adafruit Metro wired up to the MOSFET driver with a motor using the STEMMA JST PH cable:

Mini Push-Pull Solenoid wired to Trinket, activating back and forth
Solenoids are basically electromagnets: they are made of a coil of copper wire with an armature (a slug of metal) in the middle. When the coil is energized, the slug is pulled into the...
$4.95
In Stock
If the load that you are driving requires more than 5V, then it will not trigger with this circuit.
  • Board 5V to driver V+ (red wire)
  • Board GND to driver GND (black wire)
  • Board pin 3 to driver In (white wire)
  • Motor black wire to driver terminal block -
  • Motor red wire to driver terminal block +

Here is an Adafruit Metro wired up using a solderless breadboard:

  • Board 5V to driver V+ (red wire)
  • Board GND to driver GND (black wire)
  • Board pin 3 to driver In (white wire)
  • Motor black wire to driver terminal block -
  • Motor red wire to driver terminal block +

Example Code

// SPDX-FileCopyrightText: 2022 Liz Clark for Adafruit Industries
//
// SPDX-License-Identifier: MIT

#define driverPin 3

void setup() {
  while (!Serial);
  delay(1000);
  Serial.begin(115200);
  Serial.println("Basic MOSFET Driver Test");
  pinMode(driverPin, OUTPUT);
}

void loop() {
  
  digitalWrite(driverPin, HIGH);
  Serial.println("The MOSFET driver is triggered.");
  delay(1000);
  digitalWrite(driverPin, LOW);
  Serial.println("The MOSFET driver is not triggered.");
  delay(1000);
}

Upload the sketch to your board and open up the Serial Monitor (Tools -> Serial Monitor) at 115200 baud. You should see the load triggered on and off while its status is printed to the Serial Monitor.

This guide was first published on Dec 14, 2022. It was last updated on Jul 12, 2024.