Blog · · 6 min read
MOSFET, relay or driver chip? How to switch a motor, pump or heater from a microcontroller
A microcontroller pin delivers milliamps, a pump or heater needs amps. Compare MOSFETs, relays, solid-state relays and driver chips, and learn the checks that keep the switch cool and the board alive.
Almost every connected device ends up switching something bigger than itself: a pump, a fan, a valve, a heater, a motor or a strip of LEDs. The microcontroller that decides when to switch can deliver only a few milliamps at 3.3 or 5 volts. The load may want several amps at 12 or 24 volts, or even mains voltage. Something has to sit in between.
The choice of that part decides how hot the board gets, whether the device survives the first time the motor stalls, how much noise reaches the sensors and, for mains loads, whether the product can be made safe at all. This article compares the four common options and lists the checks that catch most problems before the first board is ordered.
First: what kind of load is it?
Three questions narrow the choice quickly:
- DC or AC? Batteries, USB and wall adapters give DC. A heater or lamp plugged into the wall runs on AC mains.
- How much current, and how much at start-up? A motor or pump can draw several times its running current when it starts or stalls. A cold heater element or a lamp also draws more at first.
- Does it only switch on and off, or does it need speed control or direction? A fan that should run at half speed or a motor that must turn both ways needs more than a simple switch.
If you are still choosing the motor itself, our article on stepper, DC and servo motors covers that step first.
Option 1: a MOSFET for DC loads
For DC loads up to a few amps, a single MOSFET is usually the simplest and cheapest answer. In the most common circuit, the "low-side switch", the load sits between the positive supply and the MOSFET, and the MOSFET connects it to ground when the microcontroller pin goes high.
The detail that trips up many first designs is the gate voltage. The datasheet value called "gate threshold voltage" is the point where the MOSFET only just begins to conduct, not where it is fully on. What matters is the on-resistance, written RDS(on), at the voltage your pin can really deliver. For a 3.3 V microcontroller, choose a part whose datasheet states RDS(on) at 2.5 V or lower, often called a logic-level MOSFET.
The heat in the MOSFET is roughly the current squared times that resistance. At 3 A and 20 milliohms, that is 0.18 W, which a small package handles without trouble. At 3 A and 200 milliohms, because the gate was only half on, it is 1.8 W, enough to make a small package hot enough to fail.
Add two resistors: a small one in series with the gate, typically tens of ohms, to calm the switching edges, and a larger one from gate to ground, often 10 to 100 kilohms, so the load stays off while the microcontroller starts up and its pins are still floating.
Good for: pumps, fans, valves, LED strips and small heaters on DC, switched on and off or dimmed with PWM.
Option 2: a mechanical relay
A relay is a switch moved by a small electromagnet. Its big advantage is isolation: the coil side and the contact side are electrically separate, and the contacts can switch AC or DC, so one part can turn a mains heater on and off from a low-voltage board.
The costs are real, though. The coil itself needs more current than a microcontroller pin can deliver, often 70 to 80 milliamps for a small 5 V relay, so it still needs a transistor and a diode to drive it. The contacts wear out: datasheets typically give tens of millions of operations without load but only around a hundred thousand at full rated load. A relay that clicks every few seconds in a temperature loop will reach that in weeks. It is also too slow for PWM.
Good for: switching mains or isolated loads a few times per hour or per day, such as a heater with a slow thermostat cycle or a pump that runs once a day.
Option 3: a solid-state relay
A solid-state relay does the same job with semiconductors instead of moving contacts. It is silent, does not wear out from switching and can be driven directly by a few milliamps from a logic pin in many cases.
Two cautions. First, the type must match the load: many solid-state relays for AC use a triac and cannot switch DC, while DC versions cannot switch AC. Second, they drop a volt or more internally, so they get warm at higher currents and often need a heatsink. Most also let a small leakage current through when "off", which can keep a small LED lamp glowing faintly.
Good for: AC heaters and lamps switched often, for example in a temperature controller that cycles every few seconds.
Option 4: a driver chip
When the load needs more than on and off, a dedicated driver chip saves a lot of work. An H-bridge driver lets a DC motor run in both directions and brake. Stepper drivers handle the current control and step sequence of a stepper motor. Many drivers also include protection that discrete parts do not have: current limiting, thermal shutdown and undervoltage lockout.
A driver costs a little more than a MOSFET, but it often replaces four transistors and their gate circuits, and it reports faults instead of quietly overheating.
Good for: motors that change direction, stepper motors, and any load where a stalled motor must not burn the board.
The comparison in short
| DC | AC mains | PWM / speed | Isolation | Wear | |
|---|---|---|---|---|---|
| MOSFET | yes | no | yes | no | none |
| Relay | yes | yes | no | yes | contacts wear |
| Solid-state relay | depends on type | depends on type | slow only | yes | none |
| Driver chip | yes | no | yes | no | none |
Four checks before you order the board
1. Protect against inductive kicks. Motors, pumps, valves and relay coils store energy in their windings. When the switch opens, that energy produces a voltage spike that can destroy a MOSFET. A diode across the load, pointing back towards the supply, gives the current a safe path. Driver chips often have it built in; a single MOSFET does not.
2. Size for the start-up and stall current, not the running current. Read the load's start-up or stall current and check that the switch, the traces and the connector can carry it for at least a moment.
3. Work out the heat. Use the current and the on-resistance or voltage drop to get the power, then check that the part and the enclosure can get rid of it. Our five-minute heat estimate for sealed boxes shows how to do this for the whole device.
4. Keep the power current away from the sensors. A pump switching two amps causes voltage dips and noise. Give the load its own wide ground path back to the supply and keep it away from analogue sensor inputs. A supply that sags when the load starts can also reset the microcontroller; our article on powering a hardware prototype covers how to plan for that.
A word on mains voltage
Switching mains is a different class of design. It needs proper spacing between mains and low-voltage parts on the board, a fuse, an enclosure that keeps fingers away and certification before the product is sold. For prototypes and small series, a ready-made, certified relay or SSR module in its own housing is usually the safer and faster path than putting mains on your own board.
How we handle it
On our platform, the switching stage is chosen in the electronics step from the requirements: load type, voltage, running and start-up current, and whether speed or direction control is needed. The electronics step then selects the part, adds the protection diode, gate resistors and pull-downs, and checks the heat and the trace widths. You can see small DC switching stages in two public projects: the fan in the DIY BBQ Temperature Controller and the pump in the DIY Automatic Plant Watering System.
Watch hardware get built by AI. Follow public projects on makemachine.ai, read every result in full and get an email when there is something new.
More from the blog
- Aluminium extrusion, welded steel or 3D printed? How to choose the frame for your prototype machine
- Can a satellite run a large AI model? The power and heat budget of a data center in orbit
- DC motor vs. stepper vs. servo: which one moves your prototype?
Open-hardware projects built with AI
- Data Center Satellite: I want to put a data center into orbit: a satellite that runs a large language model on board, with inference of a frontier-size model as…
- Automatic Archive Page Turner: Automatic Archive Page Turner: an open design study on makemachine. The idea came from a conversation on X, where someone wished this…
- Tile Steam-Cleaning Robot: Tile Steam-Cleaning Robot: an open design study on makemachine. The idea came from a conversation on X, where someone wished this device…
- Chute-Size Trash Compactor: Chute-Size Trash Compactor: an open design study on makemachine. The idea came from a conversation on X, where someone wished this device…
- DIY Automatic Plant Watering System: An open-hardware watering system for indoor plants: a small pump, a refillable tank and a soil moisture sensor in each pot keep up to six…
- DIY BBQ Temperature Controller: A temperature controller for charcoal grills and smokers that makers can build themselves. A pit probe, two meat probes and a small fan on…
- ZählerSchau: ZählerSchau is a small, battery-powered unit that clips onto an electricity meter in Germany (water meters via a clamp adapter), takes a…
- Roadstoy: Roadstoy is a remote-controlled toy version of the new Tesla Roadster that can briefly jump and flip using compressed air. It drives on an…
- The forever Washing machine: The forever washing machine is a washing machine offered as a service instead of a product. Customers do not buy the machine but pay for…
- Bike Light: I want to build a bike light that needs no battery. Magnets sit in the spokes close to the hub, and a coil on the fork picks up their…
- Rooficle: I want to develop a light, efficient and affordable e-bike that can be used legally on public roads in Singapore. Its core is an…
- BBQ Modular Grill: I want to design a modular grill. Instead of one sealed block, it is made of separate parts that can each be bought on their own online…