IRF540 MOSFET does not switch fully from an Arduino or ESP32: logic-level gate

The IRF540 is not a logic-level MOSFET, so it needs a gate voltage of about 10 V to turn on fully. A 3.3 V or 5 V pin does not do that.

What the message means

A MOSFET only conducts well when the gate voltage is high enough. At a low gate voltage it stays partly on, drops voltage and gets hot.

Fix it in this order

  1. Check the datasheet for the gate threshold and the on-resistance at your gate voltage.
  2. Use a logic-level MOSFET, such as one whose on-resistance is listed at 4.5 V or lower for a 5 V board, and lower still for 3.3 V.
  3. Or drive the gate with a gate driver or a transistor stage from a higher supply.
  4. Add a resistor of about 100 ohm in series with the gate, and about 10 kohm from gate to ground.
  5. Put a diode across inductive loads such as motors and relays.
  6. Use a ready-made MOSFET module if you are not sure.

Why it happens

A MOSFET conducts according to the voltage between gate and source. The datasheet gives a threshold at which it just starts to conduct, and a higher voltage is needed before the on-resistance becomes low. The IRF540 is designed for a gate drive well above what a 3.3 V or 5 V pin supplies.

At a low gate voltage the MOSFET is only partly on, so its resistance is high, voltage is lost across it and it turns that into heat. A logic-level MOSFET, or a gate driver, solves this. Check the on-resistance figure at your own gate voltage in the datasheet.

If you see this, do this

You seeDo this
MOSFET hot, load weakNot fully on. Use a logic-level part.
Load stays on at start-upAdd the pull-down resistor.

flyback diode, GPIO current limit.

Last reviewed: November 2026. These are the usual causes and the order that finds them fastest. Test on your own board; clones and cables differ.

Why this happens

A power MOSFET’s resistance between drain and source depends on the voltage between gate and source. The datasheet’s threshold voltage is where it just begins to conduct; the low on-resistance in the headline specification is given at a much higher gate voltage, often 10 V. The IRF540 is specified for that kind of drive. At 3.3 V or 5 V the channel is only partly formed, so the resistance can be many times higher.

Because power lost in the MOSFET equals the current squared times its resistance, a high resistance turns the MOSFET into a heater and takes voltage away from the load. The load runs weakly and the MOSFET gets hot, even though the circuit looks correct.

How to confirm the cause

  • Measure the voltage between gate and source with the load on. It should be near the full logic level; if the source is not at ground, the real drive is lower.
  • Measure the voltage between drain and source with the load on. A value over a few hundred millivolts at a moderate current points to partial turn-on.
  • Calculate the resistance from that voltage and the load current and compare it with the datasheet at your gate voltage.
  • Feel for a hot MOSFET only briefly and carefully, or use a thermometer probe.
  • Look in the datasheet for a table of on-resistance at 4.5 V or 2.5 V. If there is none, it is not a logic-level part.

Worked example

An illustrative check on a 2 A load, to show what the measurement tells you:

Vds measured = 0.10 V   at I = 2 A
R = V / I = 0.10 / 2 = 0.05 ohm   -> fully on, P = I x I x R = 0.2 W

Vds measured = 2.0 V    at I = 2 A
R = 2.0 / 2 = 1.0 ohm    -> only partly on, P = 2 x 2 x 1.0 = 4 W

4 W in a small TO-220 without a heat sink gets very hot.

Common mistakes

  • Choosing a MOSFET by its current and voltage rating only.
  • Leaving the gate floating at start-up; add a pull-down resistor.
  • Using a very large gate resistor, which slows switching and increases heat.
  • Switching the load on the ground side but wiring the MOSFET as a high-side switch.
  • Forgetting to join the grounds of the controller and the load supply.

If this did not fix it

  • A logic-level part chosen, but the gate drive comes from a 3.3 V pin and the part is rated at 4.5 V; check at 3.3 V.
  • A bad pin or a driver chip that cannot source enough gate current at the PWM frequency.
  • A load that is inductive and needs a flyback diode, or the MOSFET can fail.