Episode #4 · N20

The Tiny Motor Behind Almost Every Mini Robot

Smaller than your thumb, a couple of dollars, and enough torque to drive a whole robot. A DC motor plus a gearbox — the muscle behind wheeled bots.

Episode video — paste your YouTube ID to embed

What it is

The N20 is two halves: a small DC motor at the back and a gearbox at the front. A bare DC motor spins crazy fast but has no muscle; the gearbox trades that speed for torque — slower output, way more force. That's what lets a thumb-sized motor push a whole robot.

The bare minimum to use it

  • Pick your RPM: low RPM = slow + strong (climbers); high RPM = fast + weak (racers).
  • Two wires, no polarity — swap them to reverse direction.
  • Needs a driver — never wire it straight to the ESP32. Run it through a DRV8833.
  • D-shaped shaft — buy wheels/couplers made for the N20 so they don't slip.

Wiring

N20 motor (2 wires) ──▶ DRV8833 AOUT1 / AOUT2
Battery ──▶ DRV8833 VM / GND
ESP32 GND ──▶ DRV8833 GND     (common ground)
ESP32 GPIO 5/6 ──▶ AIN1/AIN2  (PWM speed + direction)
ESP32-C3 SuperMini miniRobo pin map: servos on GPIO 3 and 4, motors on GPIO 5, 6, 7 and 10, onboard LED on GPIO 8

C3 SuperMini pin map — the N20s run through the DRV8833 on GPIO 5, 6, 7 and 10.

Same control code as the DRV8833 episode — the N20 is simply what you bolt to the driver's output.

The code

A two-N20 rover with a software trim so it drives straight despite mismatched motors. Full sketch in the sidebar.

// miniRobo EP4 — two N20s, straight-line trim (ESP32)
const int AIN1=5, AIN2=6, BIN1=7, BIN2=10;
const float TRIM = 0.92;   // tune until it tracks straight

void motor(int in1,int in2,int spd){
  spd = constrain(spd,-255,255);
  analogWrite(in1, spd>=0? spd:0);
  analogWrite(in2, spd<0? -spd:0);
}
void setup(){ for(int p:{AIN1,AIN2,BIN1,BIN2}) pinMode(p,OUTPUT); }
void loop(){
  int base = 200;
  motor(AIN1,AIN2, base);            // left
  motor(BIN1,BIN2, base*TRIM);       // right, trimmed
}

What I wish I knew

  • Buy the right RPM. Too fast = weak and spins out; too slow = crawls. Pick fast or strong before you buy.
  • N20-specific wheels only. The D-shaft is a particular size; random wheels slip.
  • Don't stall it. A jammed, powered motor pulls max current and cooks itself.
  • Add a ceramic cap across the terminals to kill electrical noise at the source.
  • Two motors won't match — trim one in code, or use the encoder version for straight lines.