Reference 02 Driving a load from an MCU pin ↑ Contents Built from Lesson 02

The pin budget

Three gates every load must pass before it can hang off a microcontroller pin — and the one component that fixes each.

The three gates

1 · Current Is the load's worst-case draw below the pin's drive strength? Fails → transistor, fed from the load supply.
2 · Voltage Is the load's rated voltage at or below the pin's output high level? Fails → separate supply rail for the load.
3 · Transient Is the load non-inductive, or already clamped? Fails → flyback diode across the load.

The gates are independent. Fixing one does nothing for the others. All three must pass for direct drive.

ESP32 pin limits

Source, per pin40 mA
Sink, per pin28 mA
Output high0.8 × VDD
Cumulative, all pins1200 mA
Abs max pin voltage3.6 V

Per-pin source current falls from ~40 mA toward ~29 mA as more pins in the same domain source at once. Treat 40 mA as a ceiling, not an allowance.

Motor current: which number

Design against stall current, never free-run. A spinning motor generates a voltage opposing its supply; that is what limits current. At zero speed there is none.

Istall = Vsupply / Rwinding

Every motor passes through stall on every start, and returns to it whenever the load jams. Stall is typically 7–13× free-run.

Pololu 6 V micro gearmotors
Free-runStall
LP50 mA360 mA
MP80 mA670 mA
HP120 mA1600 mA

Measuring stall current with a DMM

  1. Motor disconnected, unpowered.
  2. Short the probes; note the lead resistance.
  3. Measure across the motor terminals on the lowest range.
  4. Rotate the shaft slightly; measure again. Repeat 5–6 times — the commutator makes the reading move.
  5. Take the lowest reading, minus lead resistance.
  6. Istall = Vsupply ÷ R.

Gives the steady stall current. Says nothing about the switching transient — that is gate three.

Powering the load

  • Load current must never flow through the MCU or its dev board.
  • Load supply → load → transistor → ground. Pin drives the transistor only.
  • Tie the grounds together. A switch with no shared reference does nothing.
  • Motor current through a dev board regulator or USB connector browns out the 3.3 V rail and resets the MCU mid-motion. Looks like a firmware bug; isn't.

When direct drive IS fine

All three gates pass:

  • LED with series resistor (~10 mA, 3.3 V, not inductive)
  • Logic input on another chip
  • Small piezo beeper (the element is capacitive)

The rule is not “never drive from a pin”. It is check all three, every time.

Failure signatures

  • Works unloaded, dies under load → gate one. Sized against free-run instead of stall.
  • Runs but weak and slow → gate two. Load rated above what the pin or rail delivers.
  • MCU resets when the motor starts → load current is flowing through the board's supply. Separate the rails.
  • Pin dead, everything else fine → gate three, or gate one, or both.

Sources