Summary
Relays and MOSFETs both switch electrical loads, but they are suited to different applications. Learn when to use each based on load type, switching speed, current, isolation, PWM and safety.
Use a relay when you need electrical isolation or need to switch AC and DC loads with simple ON/OFF control. Use a MOSFET for low-voltage DC loads that need fast switching, PWM, silent operation, or high switching frequency. For Arduino projects, the right choice depends on load type, voltage, current, switching speed, isolation, and how often the load is switched.
Relay vs MOSFET: Quick Comparison
| Feature | Relay | MOSFET |
|---|---|---|
| Switching type | Electromechanical | Semiconductor |
| Switching speed | Typically milliseconds | Typically nanoseconds to microseconds |
| AC switching | Yes | Not with a single standard MOSFET |
| DC switching | Yes | Yes |
| PWM | Not suitable | Excellent |
| Electrical isolation | Inherent between coil and contacts | Not inherent |
| Moving parts | Yes | No |
| Switching noise | Audible click | Silent |
| Contact wear | Yes | No mechanical contacts |
| Power consumption | Coil consumes power while active | Very low gate power in steady state |
| Heat | Contact losses | Depends on RDS(on) and current |
| Best for | AC, isolation, simple ON/OFF | DC, PWM, frequent switching |
| Arduino use | Relay module | Logic-level MOSFET module/circuit |
A relay uses an electromagnetic coil to physically move contacts. A MOSFET switches electronically through its gate. That fundamental difference determines their speed, isolation, lifespan, and suitable applications. H-Tec Electric
What Is a Relay?
A relay is an electrically controlled switch. When its coil is energized, an electromagnetic mechanism changes the state of its contacts.
A typical relay provides:
- COM — Common terminal
- NO — Normally Open
- NC — Normally Closed
When the relay is OFF, COM is connected to NC. When the relay is energized, COM switches to NO.
This lets a low-voltage control circuit operate a separate load circuit.
Arduino itself provides relay shields specifically because its digital I/O cannot directly handle high-power loads. Arduino Documentation
Where are relays useful?
Use a relay for:
- AC lamps
- Fans
- Pumps
- Appliances
- Solenoids
- Low-frequency ON/OFF control
- Applications requiring isolation
- Loads where the controller and load operate at different voltage levels
A relay is especially useful when the load is AC because the mechanical contacts can switch AC directly within their rated voltage and current limits.
What Is a MOSFET?
A MOSFET is a semiconductor switching device controlled by voltage applied to its gate.
For a typical N-channel MOSFET used as a low-side switch:
- Gate → control signal
- Drain → load
- Source → ground
Unlike a relay, it has no moving contacts.
This allows MOSFETs to switch much faster and makes them suitable for applications such as:
- DC motors
- LED strips
- Solenoids
- DC fans
- PWM speed control
- LED dimming
- Battery-powered systems
- Power converters
MOSFETs are particularly useful when the load needs to be switched repeatedly or controlled using PWM. H-Tec Electric
Relay vs MOSFET: Switching Speed
MOSFETs are much faster than mechanical relays.
A relay has to physically move its contacts, so its switching time is typically measured in milliseconds. MOSFETs can switch in nanoseconds to microseconds depending on the device and gate-drive circuit. H-Tec Electric
Why does switching speed matter?
If you only need to turn a lamp ON once every few minutes, relay speed is usually irrelevant.
If you need to switch a motor hundreds or thousands of times per second for PWM control, a relay is unsuitable.
For example:
DC motor speed control → MOSFET
230V AC lamp ON/OFF → Relay
A relay's mechanical contacts are not designed for high-frequency switching. Repeated rapid switching causes contact wear and can result in arcing or premature failure.
Relay vs MOSFET: Current Capacity
Do not choose either component based only on the advertised maximum current.
For a relay, check:
- Contact voltage rating
- Contact current rating
- AC vs DC rating
- Resistive vs inductive load
- Switching frequency
- Electrical life
For a MOSFET, check:
- Continuous drain current
- Pulsed drain current
- Drain-source voltage rating
- RDS(on)
- Gate-drive voltage
- Thermal limits
- Package and PCB cooling
A MOSFET may have a high headline current rating but still require significant heat dissipation at the current you actually use.
MOSFET power loss
When a MOSFET is fully ON, conduction loss can be approximated as:
P = I² × RDS(on)
For example, if a MOSFET has an RDS(on) of 20 mΩ and carries 5A:
P = 5² × 0.020 = 0.5W
That 0.5W becomes heat that the MOSFET and PCB must dissipate.
So a 30A-rated MOSFET is not automatically suitable for continuously switching 30A in every circuit.
Relay vs MOSFET: Electrical Isolation
This is one of the biggest reasons to choose a relay.
A mechanical relay separates the control circuit from the load through its physical contact arrangement. This provides galvanic isolation between the coil side and contact side when the relay and PCB are designed appropriately.
A basic MOSFET does not provide galvanic isolation. The controller and load circuit generally share a common electrical reference.
This means:
- Need simple isolation → Relay
- Need fast DC switching → MOSFET
- Need both → Use an isolated MOSFET driver or an appropriate SSR/relay architecture
The isolation provided by a relay is particularly useful when a low-voltage Arduino is controlling a separately powered load. WIN SOURCE BLOG
Relay vs MOSFET: Which One Should You Use?
Use this decision table:
| Application | Better choice |
|---|---|
| 230V AC lamp ON/OFF | Relay |
| AC appliance control | Relay |
| 12V DC LED strip ON/OFF | MOSFET |
| LED brightness control | MOSFET |
| DC motor speed control | MOSFET |
| High-frequency switching | MOSFET |
| Battery-powered DC switching | MOSFET |
| Need galvanic isolation | Relay |
| Need audible switching feedback | Relay |
| Need silent operation | MOSFET |
| Infrequent ON/OFF switching | Either, depending on load |
| Frequent switching | MOSFET |
When Should You Use a Relay?
Choose a relay when:
1. You are switching AC
A standard mechanical relay can switch AC loads within its rated specifications.
A single standard N-channel MOSFET is primarily used for DC switching. AC switching with MOSFETs requires additional circuitry, such as back-to-back MOSFETs or an appropriate solid-state switching design. WIN SOURCE BLOG
2. You need galvanic isolation
A relay physically separates the coil and contact circuits.
3. You only need ON/OFF control
If a pump only needs to run for 10 seconds and stop, there is little benefit in using high-speed semiconductor switching.
4. The load voltage is significantly different from the Arduino
A relay module can provide a convenient interface between low-voltage control electronics and the load side.
When Should You Use a MOSFET?
Choose a MOSFET when:
1. The load is DC
MOSFETs are particularly effective for low-voltage DC loads.
2. You need PWM
PWM can control:
- Motor speed
- LED brightness
- Fan speed
- Heater power
A MOSFET can switch rapidly enough for these applications.
3. You need silent operation
A MOSFET has no mechanical contacts, so it does not produce the clicking sound associated with a relay.
4. The load switches frequently
There is no mechanical contact wear, making MOSFETs suitable for high-cycle applications.
5. Battery efficiency matters
A relay coil continuously consumes power while energized. A MOSFET gate consumes very little steady-state power, although the complete driver circuit and switching losses still need to be considered. WIN SOURCE BLOG
How to Connect a Relay Module to Arduino
A relay module is easier to use with Arduino than a bare relay because the module generally includes the driver circuitry needed to control the relay.
A typical module has:
- VCC
- GND
- IN
and load terminals:
- COM
- NO
- NC
Arduino-side wiring
For a typical 5V relay module:
| Relay module | Arduino Uno |
|---|---|
| VCC | 5V |
| GND | GND |
| IN | Digital output pin |
Arduino's Uno GPIO pins are rated for 20 mA as a recommended operating condition, so a relay coil should not be driven directly from a GPIO. Use a relay module or a properly designed transistor/MOSFET driver circuit. Arduino Documentation
Example Arduino code
const int relayPin = 7;
void setup() {
pinMode(relayPin, OUTPUT);
}
void loop() {
digitalWrite(relayPin, HIGH);
delay(5000);
digitalWrite(relayPin, LOW);
delay(5000);
}
Important: Some relay modules are active LOW, meaning LOW turns the relay ON and HIGH turns it OFF. Check the module documentation before using the code.
How to Connect a MOSFET to Arduino
For a simple low-side DC switching circuit using an N-channel logic-level MOSFET:
Arduino PWM pin ── Gate
|
MOSFET
|
GND ───────────── Source
DC supply + ───── Load ───── Drain
The Arduino controls the MOSFET gate, while the external power supply provides current to the load.
For a practical circuit, add:
- Gate resistor where appropriate
- Gate pull-down resistor
- Flyback diode for inductive loads
- Common ground between Arduino and the MOSFET source/supply negative when using a non-isolated driver
Why use a logic-level MOSFET?
A logic-level MOSFET is designed to achieve low resistance with the gate voltage available from a microcontroller.
Do not select a MOSFET only because its datasheet says it has a low RDS(on). Check the gate voltage at which that RDS(on) is specified.
What Is the Difference Between a Relay Module and a Bare Relay?
A bare relay is only the electromechanical switching component.
A typical relay module adds components such as:
- Transistor driver
- Flyback diode
- LED indicator
- Resistors
- Screw terminals
- Sometimes an optocoupler
This makes the module much easier to connect to an Arduino.
Arduino's own relay shield schematics show relay-driver transistors and flyback diodes as part of the relay control circuit. Arduino Documentation
For beginners
Use a relay module rather than connecting a bare relay coil directly to an Arduino GPIO.
What Is a Flyback Diode and Why Do You Need One?
A relay coil is an inductive load.
When current flows through the coil, energy is stored in its magnetic field. When the current is suddenly switched off, the collapsing magnetic field produces a voltage spike.
A flyback diode provides a path for that stored energy and limits the voltage spike.
For a DC relay coil:
+V
|
Relay
Coil
|
+--------|<|--------+
| Diode |
| |
+-------------------+
The diode is normally reverse-biased while the coil is powered and conducts when the coil is switched OFF.
Relay modules commonly include this protection. Arduino's MKR Relay Shield schematic, for example, includes a flyback diode across each relay driver circuit. Arduino Documentation
What about a motor?
A DC motor is also inductive.
When switching a DC motor with a MOSFET, use appropriate flyback or transient protection across the motor. The protection device must be selected according to the motor's voltage, current and switching arrangement.
Do You Need a Flyback Diode With a Relay Module?
Usually, no additional diode is needed if the relay module already includes one.
Check the module schematic or specifications first.
If you are building a relay driver from individual components, include suitable coil suppression.
For an inductive load being switched through the relay contacts, the protection requirement is different. A diode is appropriate for a DC inductive load, while AC loads require suitable suppression such as an RC snubber or other correctly rated transient protection. Projectech
Can a Relay Switch DC and AC?
Yes, provided the relay contacts are rated for the specific voltage, current and load type.
However, AC and DC contact ratings are not interchangeable.
For example, a relay may be rated for a particular AC current but have a lower DC rating.
Always check the datasheet for:
- AC voltage
- DC voltage
- AC current
- DC current
- Resistive load rating
- Motor/inductive load rating
- Electrical life
Do not assume that a relay marked “10A” can switch every 10A load at every voltage.
Can a MOSFET Replace a Relay?
Sometimes, but not always.
A MOSFET can replace a relay when:
- The load is DC.
- Isolation is not required.
- Fast switching is useful.
- PWM is required.
- The MOSFET voltage and current ratings are sufficient.
- The gate can be driven correctly.
A MOSFET is not a simple drop-in replacement for a relay when you need:
- AC switching
- Galvanic isolation
- Physical disconnection
- Simple polarity-independent switching
For AC loads, an SSR, TRIAC-based circuit, or appropriately designed back-to-back MOSFET arrangement may be more suitable depending on the application.
Relay vs MOSFET for Arduino Motors
For a DC motor, MOSFET is usually the better choice for electronic speed control.
A relay can turn a motor ON or OFF, but it cannot provide normal high-frequency PWM speed control.
For example:
Relay:
Motor OFF → Motor ON → Motor OFF
MOSFET + PWM:
20% duty cycle → 50% → 80% → 100%
This allows the controller to regulate the average power delivered to the motor.
For reversing a DC motor, however, a single MOSFET is not enough. Use an appropriate H-bridge motor driver.
Relay vs MOSFET: Common Mistakes
Connecting a relay coil directly to an Arduino pin
Arduino Uno GPIO pins are not intended to power relay coils directly. Use a relay module or driver circuit. Arduino Documentation
Choosing a MOSFET by current rating alone
Check RDS(on), gate-drive voltage, voltage rating and thermal performance.
Using a standard MOSFET for AC
A single conventional MOSFET is not a straightforward AC switch.
Using a relay for PWM
Mechanical contacts are not designed for rapid PWM switching.
Forgetting the flyback diode
Inductive loads can generate voltage spikes when switched off.
Ignoring the load type
A relay's current rating for a resistive load may not apply to motors, pumps or other inductive loads.
Ignoring isolation
A MOSFET does not automatically isolate the Arduino from the load.
Switching mains without proper protection
A relay module does not make mains electricity safe by itself. Proper insulation, enclosure, fusing, clearances, grounding and installation practices are required.
Relay vs MOSFET: Which One Should You Choose?
Use this simple rule:
AC or isolation → Relay
DC + PWM or frequent switching → MOSFET
Simple DC ON/OFF → Either, depending on isolation, current, cost and switching frequency
For Arduino projects, the load should determine the switching device—not the other way around.
If you are switching a 230V AC appliance, a correctly rated relay or appropriate SSR is usually the practical approach. If you are controlling a 12V LED strip or varying a DC motor's speed, a properly selected MOSFET is generally the better choice.
Final Verdict
Relays are best when isolation, AC switching and simple ON/OFF control matter. MOSFETs are best for DC loads, PWM, fast switching and frequent operation.
For an Arduino project, first identify the load voltage, current, AC/DC type and switching frequency. Then check isolation requirements and select the appropriate relay or logic-level MOSFET with adequate voltage, current and thermal margins.
When working with mains voltage, do not rely on a relay module alone for safety. Use appropriate protection and installation practices, and avoid exposed live wiring.