# ESP32 GPIO LED and load current: use a resistor or a transistor

> ESP32 GPIO pins give only a small current. Use a series resistor for LEDs and a transistor or driver for relays, buzzers and motors.

Canonical: https://roboticsengineering.in/fix/esp32-gpio-led-current-limit-use-resistor-transistor/ | Published: 2026-11-03 | Updated: 2026-11-04

**A GPIO pin is a signal, not a power supply.** Always use a series resistor with an LED and a transistor or driver for anything larger.

## What the message means

The pin driver can supply only a small current. Overloading it can make the pin misbehave or damage the chip.

## Fix it in this order

1. Put a resistor of about 220 ohm to 1 kohm in series with an LED, depending on brightness.
2. Use a transistor or MOSFET module to switch relays, buzzers and motors, powered from a separate supply.
3. Check the datasheet for the current limits of the pin and of the whole chip.
4. Join the grounds of the load supply and the board.
5. Use a flyback diode with coils.

## Why it happens

An ESP32 pin can only supply a small current, so connect an LED through a series resistor, for example 220 Ω to 330 Ω from a 3.3 V pin. Never drive a relay, a motor or a strip of LEDs directly from a pin.

For anything that needs more current, switch it with a transistor or a MOSFET and power it from a separate supply with a shared ground. Check the datasheet for the current limit of your module.

## If you see this, do this

| You see | Do this |
| --- | --- |
| LED very dim or board resets | Check the resistor and the supply. |
| Pin stops working | Overloaded. Replace the board and add a driver. |

## Related

[flyback diode](https://roboticsengineering.in/fix/flyback-diode-relay-motor-spikes-reset-board/), [LED resistor calculator](https://roboticsengineering.in/led-resistor-voltage-divider-calculator/).

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 GPIO pin is a weak driver. The ESP32 datasheet lists a maximum current per pin in the tens of milliamps, and a safe working figure is lower, commonly 10 to 20 mA; check the datasheet for your module. The output is 3.3 V, so the LED needs a series resistor to limit current, and anything bigger than a small LED, such as a relay coil, a motor or an LED strip, needs a transistor or MOSFET.

The resistor value follows from Ohm’s law: R = (Vpin − Vf) ÷ I. For a red LED with a forward voltage near 2.0 V at 10 mA, R = (3.3 − 2.0) ÷ 0.010 = 130 Ω, so use the next standard value, 150 Ω, which gives about 8.7 mA. Blue and white LEDs have forward voltages near 3 V, which leaves too little headroom on 3.3 V to set the current well.

## How to confirm the cause

- Measure the voltage across the series resistor with the LED lit and divide by its resistance. 1.3 V across 150 Ω is 8.7 mA.
- Measure the voltage at the pin while the load is on. A big sag below 3.3 V means you are asking too much of it.
- Add up the currents of all pins used at once and compare with the module’s limits.
- Check the pin number: GPIO 34 to 39 are inputs only, and other pins have boot-time meaning.
- For a transistor stage, measure the base current and the collector voltage with the load on.

## Worked example

A switch stage for a load around 100 mA, using an NPN transistor such as a 2N2222 or BC547 with a base resistor. Check your own part’s datasheet.

```
base resistor 1 kΩ from GPIO to transistor base
I_base = (3.3 V - 0.7 V) / 1000 Ω = 2.6 mA
  transistor gain of 100 needs only 1 mA of base current
  2.6 mA drives it into saturation with margin
emitter to GND, load between supply and collector
coil loads: add a diode across the coil (flyback)
```

## Common mistakes

- Connecting an LED straight to a pin with no resistor.
- Driving a relay coil or motor from a pin.
- Leaving out the flyback diode on an inductive load.
- Forgetting that the transistor and the ESP32 need a common ground.
- Using a pin that is held at start-up by boot-mode rules.

## If this did not fix it

- A blue or white LED that is dim because 3.3 V is nearly its forward voltage.
- A MOSFET that is not logic level and does not turn on at 3.3 V.
- A load supply that sags when it switches on.
- A resistor value read wrongly from colour bands.
