When you want to switch high currents or voltages with an Arduino or similar microcontroller, relays and MOSFETS are likely to be your top component choices for doing the actual switching. Both types of components are available with voltage and current ratings in hundreds of volts and amps, and, when properly implemented, can do a wide range of power switching safely and efficiently.
But how do relays and MOSFETs actually compare? Which should you pick for each power switching task, and how do they go along with an Arduino or with other similar microcontrollers?
In this article, I will give a quick comparison of mechanical relays and MOSFETs in power switching with Arduinos. In short, mechanical relays are robust, safe, and excellent for AC line power switching, but are slower, bulkier, less efficient with DC and trickier to drive with an Arduino. MOSFETs are fast, highly efficient with DC and easy to drive, but they are not isolated and cannot switch AC voltages. Relays are better for AC line power switching tasks and MOSFETs DC.
We will next go through the differences between power relays and MOSFETs in more detail, with an eye on hobbyist microcontroller applications. The comparison is divided into nine sections, and for those of you in a hurry, summarized in the table below. We will finish by looking at how relays and MOSFETs compare in three common modes power switching: AC, DC, and PWM power switching.
|DC switching||30 VDC (typ.)||12…600 VDC|
|AC switching||250 VAC||N/A|
|Current rating||5…20 A (typ.)||2…200 A (typ.)|
|Control voltage||3.3V, 5V||3.3V, 5V|
|Control current||5…100 mA||0 mA DC, transient|
|Switching time||5…50 ms||0.1 … 5 us|
|ON-Resistance, typ.||< 100 mOhm||1…50 mOhm|
|Service life||50k…100k operations||unlimited|
|Size||brick, ½…2” length||TO packages|
|Price||$1…$3 typ.||$0.10…$3 typ.|
|Applications||AC switching||DC switching, PWM|
1 Voltage ratings
Both relays and MOSFETS are available in a wide range of voltage ratings, extending up to kilovolts. The two power switch types differ
Relays can switch both AC and DC voltages. Most power relay models are rated for at least AC line voltages of 110V or 220..240V. For switching DC, their voltage ratings are substantially lower, typically under 100V.
Power MOSFETs, by contrast, can only switch DC voltages. The voltage ratings of MOSFETs vary from 12V all the way up to 1000V. Although single power MOSFETs cannot switch AC voltages, some configurations of multiple MOSFETs achieve this too.
2 Current ratings
Power relays are commonly rated for AC line currents from 2 to 20 amps, although some large models in buildings and heavy equipment can switch substantially more. However, the DC current ratings of relays are typically only a fraction of the AC rating due to arc dynamics.
Power MOSFETs are available with DC current ratings from a few amps all the way up to 600A – the ratings vary over a wider range than those of common relays. As noted, power MOSFETs cannot be used to switch AC current, and do not have corresponding ratings.
3 Ease of driving
Relays take a substantial control current through their coil to actuate, and may be heavy to switch directly using an Arduino. The required coil current varies from tens of milliamps to tens of amps depending on the model, and is achieved with control voltages upwards from 3V. Further, most relays are non-latching, and will require a steady control current to stay switched.
While 5V Arduinos (Uno, Mega, Leonardo, Pro, Micro, Nano) may be able to push enough current from their digital pins to actuate the smallest relays, external coil driver circuitry is usually required with larger relays. Arduinos with 3.3V logic (Due, MKR, Zero), on the other hand, can usually sink or source only around 5 mA, and will always need auxiliary circuitry to drive relays.
Relay coils also produce inductive voltage spikes on switching, which have to be suppressed using additional circuitry to prevent damage to the Arduino or other components in the driving circuit.
MOSFETs, on the other hand, take only a small transient current to their gate to switch, and no DC current to keep their state. However, many power MOSFETs may require a high gate voltage at 5V or more to switch properly, which the digital output of 3.3V Arduino models cannot provide.
This issue can be solved by using gate driver circuitry between the power MOSFET and the Arduino, or by selecting special low gate drive or logic level MOSFETs compatible with 3.3V. Logic level MOSFETs can be driven directly from an Arduino without any added circuitry, and make MOSFETs the easier power switching option. See my article on choosing MOSFETs for Arduino.
4 Switching speed
Relays require mechanical motion of the contacts to change state, and are relatively slow to switch. Typical switching times for power relays are in tens of milliseconds (5…50 ms), and are affected by the voltage waveform and formation of arcs between the contacts.
MOSFETs have no moving components and can be switched extremely fast. The switching speed is mostly limited by the gate driver’s ability to rapidly charge and discharge the capacitive MOSFET gate. Typical switching times for power MOSFETs driven directly from Arduino digital pins are from hundreds of nanoseconds to some microseconds (100 ns … 5 us).
Relays provide galvanic isolation between the control circuit and the load circuit, as these two circuits completely separated in the component. With typical insulation resistance and dielectric strength in the order of 1 GOhm and 1…3 kV, respectively, the isolation provided by relays is excellent and minimizes the risk of the control circuit being exposed to line voltage.
MOSFETs, by contrast, do not isolate the control and the load circuits completely. While the MOSFET gate is isolated from the channel, this isolation is very weak and has a breakdown voltage of only some tens of volts. Further, to operate properly the MOSFET must share the ground level with the controller, which potentially exposes the control circuit to the full load voltage being switched.
Relays are specified to have a relatively low resistance at a fraction of an ohm when switched to conduction. The ratings are mostly given as maximum resistance, for which a value of 100 mOhm is common. The actual resistance is difficult to predict as it varies depending on the voltage and current levels, voltage waveform, arc formation and relay wear.
MOSFETs are available with a wide range of ON-resistances from a few milliohms to several ohms. Values of some tens of milliohms are typical for the average power MOSFET. However, the best models achieve extremely low resistances around one milliohm, and very efficient power switches.
7 Service life
Relays suffer from wear and have a finite service life. The wear is mainly in the contact surfaces, which erode due to arcing during switching. Small relays are typically specified to last at least 50,000 to 100,000 operations at full specified switching load.
MOSFETs have no wearing parts and will last indefinitely if used properly. However, MOSFETs are more sensitive than relays, and may be damaged by overheating, overvoltage or voltage spikes, to which the gate is particularly sensitive.
Relays come in a wide range of form factors and packages. Most of the smaller relays suited for use with an Arduino are rectangular bricks ½’’ to 2’’ long and with leads for through-hole PCB mounting.
Power MOSFETs come in standard through-hole or surface mount PCB component packages, common ones being TO-220, TO-252, TO-263 and SOT-23. In all of these packages, MOSFETs are as such clearly smaller than most relays. Note that with high currents, the heat sink required to cool down the MOSFET will be substantially larger than the component itself.
Small power relays suited for use with microcontrollers cost from $1 upwards in small quantities; typical price is between $1 and $2. Due to the mechanical complexity of the part, relays are never very cheap.
Power MOSFETs vary a lot in price: cheap jellybean parts may be available at just $0.10 a piece, while parts with better specs or higher voltage and current ratings may cost a few $, both in small quantities.
After this comparison of properties, let us quickly see which one of the two power switchers – relays and MOSFETs – should you prefer in some common power switching applications with microcontrollers.
AC switching: Relays
Relays are the best choice for switching AC line voltages to line-power devices such as lamps, motors and heaters – in fact, they are the only choice, since power MOSFETs cannot switch AC. For their size, relays have very good AC specifications, and perform actually much better at AC than DC. They also provide isolation into your circuit, minimizing the risk of hazardous line voltages leaking to the low-voltage parts of the circuit.
That said, more advanced configurations of multiple MOSFETs can be used to switch AC – for more details, see SSRs.
DC switching: MOSFETs
Both relays and MOSFETs can be used with Arduino to switch common DC voltages between 5V and 100V to devices such as pumps, motors, heaters and LEDs.
However, MOSFETs are usually the better choice for DC, as they offer superior DC current and voltage ratings and higher efficiency, and are also easier to use.
PWM control: MOSFETs
MOSFETs are the better choice for PWM power switching with Arduino. Of the two, MOSFETs are actually the only choice, as the switching speed of relays is wholly insufficient for PWM.
To see this, consider that the standard Arduino 500 Hz PWM has a period of 2 milliseconds. Compare this to the typical relay switching times of 2…50 ms, and you see that the relay too slow to switch even once in the PWM period.