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
The gates are independent. Fixing one does nothing for the others. All three must pass for direct drive.
ESP32 pin limits
| Source, per pin | 40 mA |
|---|---|
| Sink, per pin | 28 mA |
| Output high | 0.8 × VDD |
| Cumulative, all pins | 1200 mA |
| Abs max pin voltage | 3.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.
Every motor passes through stall on every start, and returns to it whenever the load jams. Stall is typically 7–13× free-run.
| Free-run | Stall | |
|---|---|---|
| LP | 50 mA | 360 mA |
| MP | 80 mA | 670 mA |
| HP | 120 mA | 1600 mA |
Measuring stall current with a DMM
- Motor disconnected, unpowered.
- Short the probes; note the lead resistance.
- Measure across the motor terminals on the lowest range.
- Rotate the shaft slightly; measure again. Repeat 5–6 times — the commutator makes the reading move.
- Take the lowest reading, minus lead resistance.
- 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
- ESP32 Series datasheet — Tables 5-1, 5-3
- Pololu micro metal gearmotors — free-run and stall figures
- EDN — Getting a handle on brushed DC motor current
- Reference 01 — Driving an inductive load (gate three in detail)