Phase 1 -- Left-side motors (Channel A only) via TB6612FNG + ESP32
How It All Works
Read this once before touching any wires. It makes every connection below feel obvious rather than arbitrary.
The three pieces of hardware
ESP32 — the brain. A microcontroller you write code on. It runs your program, decides which direction each wheel spins, and how fast. It speaks in digital signals: a pin is either HIGH (3.3V) or LOW (0V). It cannot directly power a motor — it can only give instructions.
TB6612FNG — the muscle. A motor driver chip. It sits between the ESP32 and the motors. It listens to the ESP32's low-current logic signals and uses them to switch the high-current battery power to the motor terminals. Think of it as a relay: a tiny signal flips a big switch.
2× 18650 battery (7.4–8.4V) — the muscle fuel. Powers the motors through the TB6612FNG. Also feeds a buck converter that steps 8.4V down to a safe 5V for the ESP32. The ESP32 then steps that 5V down to 3.3V for its own logic. One battery pack, three voltage levels.
Channels A and B
The TB6612FNG has two independent half-H-bridge channels. Each channel is a completely separate motor circuit. Channel A drives the left wheels; Channel B drives the right wheels. They share power (VM, VCC, GND) but have their own control pins and output pins.
What each TB6612FNG pin actually does
Pin
Direction
What it does
VCC
input
Powers the chip's internal logic (2.7–5.5V). Comes from ESP32's 3.3V pin. Without this, the chip won't listen to any signals.
VM
input
Motor supply voltage (up to 15V). Raw battery power goes here. This is the energy source that actually spins the motors. Completely separate from VCC.
GND
both
Common ground. Must be shared between ESP32, TB6612FNG, and the battery minus terminal. Without a shared ground, voltage levels mean nothing — signals float randomly.
AIN1 / BIN1
input
Direction bit 1 for channel A / B. HIGH or LOW. Set by the ESP32 GPIO.
AIN2 / BIN2
input
Direction bit 2 for channel A / B. AIN1 and AIN2 together form a 2-bit command: forward, backward, brake, or coast. See the direction table below.
PWMA / PWMB
input
Speed control for channel A / B. A PWM signal from the ESP32. While AIN1/AIN2 decide direction, PWMA controls how much of the battery voltage reaches the motor on each cycle. PWM = 0 means the motor gets nothing even if direction pins say forward. PWM = 255 means full voltage, full speed.
AO1 / BO1
output
Motor terminal 1 for channel A / B. Connects to one wire of the motor. Voltage swings between 0V and VM (~8.4V) depending on direction.
AO2 / BO2
output
Motor terminal 2 for channel A / B. The motor spins because there is a voltage difference between AO1 and AO2. Reverse which one is high and the motor reverses.
How PWM controls speed
PWM = Pulse Width Modulation. Instead of a steady voltage, the ESP32 pulses the PWMA pin on and off thousands of times per second. The motor sees the average voltage. If the pin is HIGH 50% of the time (duty cycle 50%), the motor behaves as if it got half the supply voltage — half speed. If HIGH 100% of the time, full speed. If HIGH 0% of the time, stopped.
The most common beginner mistake: missing shared ground. If the ESP32 GND and the battery minus are not connected through the same TB6612FNG GND pin, the ESP32's HIGH/LOW signals have no reference point — the motor driver literally can't interpret them. Wire ground first, always.
Schematic
GND (black wire)
3V3 / VCC (orange)
GPIO 27 → AIN1 (blue)
GPIO 26 → AIN2 (green)
GPIO 14 → PWMA (purple)
Motor Wire A → AO1 (yellow)
Motor Wire B → AO2 (gray/white)
Battery + → VM (red)
Buck 5V out → ESP32 VIN (dark orange)
Phase 2: Right-Side Motors (Channel B)
3 new M-F wires from ESP32 + 2 motor wires into breadboard. Everything else stays as-is.
GPIO 25 → BIN1 (white)
GPIO 33 → BIN2 (yellow)
GPIO 12 → PWMB (coral)
Motor Wire C → BO1 (green)
Motor Wire D → BO2 (black)
ESP32 to TB6612FNG -- 3 new M-F wires
Wire
From (ESP32)
To (TB6612FNG)
Purpose
White
GPIO 25
BIN1
Right direction control 1
Yellow
GPIO 33
BIN2
Right direction control 2
Coral
GPIO 12
PWMB
Right speed control (PWM)
Right-side motors -- splice first, then into breadboard
Wire
From (Motors)
To (TB6612FNG)
Purpose
Wire C
Right Front Red + Right Rear Black
BO1
Right motor output 1
Wire D
Right Rear Red + Right Front Black
BO2
Right motor output 2
Wiring Steps (5 steps)
1
Splice right-side motors (anti-parallel)
Same as left side: twist front-right red + rear-right black together (Wire C).
Twist rear-right red + front-right black together (Wire D).
2
ESP32 GPIO 25 → BIN1white M-F wire
Female on ESP32 GPIO 25, male into breadboard free hole next to BIN1.
3
ESP32 GPIO 33 → BIN2yellow M-F wire
Female on ESP32 GPIO 33, male into breadboard free hole next to BIN2.
4
ESP32 GPIO 12 → PWMBcoral M-F wire
Female on ESP32 GPIO 12, male into breadboard free hole next to PWMB.
5
Spliced wires into breadboard
Wire C (front red + rear black) → free hole next to BO1.
Wire D (rear red + front black) → free hole next to BO2.
No extra power or ground wires needed.
Channel B shares VM, VCC, GND, and STBY with Channel A. The 5 connections above are everything.
Channel B direction control (same logic as Channel A):
BIN1 (GPIO 25)
BIN2 (GPIO 33)
PWMB (GPIO 12)
Result
HIGH
LOW
0-255
Right wheels forward
LOW
HIGH
0-255
Right wheels backward
LOW
LOW
any
Coast
HIGH
HIGH
any
Brake
TB6612FNG Breadboard Pin Map
Pin orientation: The TBFNG.jpeg photo shows the back of the module.
When placed on the breadboard (component side up), left and right are mirrored.
Flip your module over briefly to confirm which pin is at each position.
Power/Output side (toward breadboard edge)GNDVCCAO1AO2BO2BO1VMGND******** ======================== center trench ========================***.***.PWMAAIN2AIN1NCBIN1BIN2PWMBGND Control side (toward center of breadboard)* = Channel A * = Channel B (new) . = unused
All Connections (12 total)
ESP32 to TB6612FNG -- all M-F wires (female on ESP32 pin, male into breadboard free hole next to TB6612FNG pin)
Wire
From (ESP32)
To (TB6612FNG)
Purpose
Black
GND
GND
Common ground
Orange
3V3
VCC
Logic power (3.3V)
Blue
GPIO 27
AIN1
Direction control 1
Green
GPIO 26
AIN2
Direction control 2
Purple
GPIO 14
PWMA
Speed control (PWM)
Battery to TB6612FNG -- bare wires from battery holder into breadboard
Wire
From (Battery)
To (TB6612FNG)
Purpose
Red
Battery +
VM
Motor power (8.4V)
Black
Battery -
GND
Battery ground
Buck Converter (LM2596S) -- 4 wires
The buck converter sits off the breadboard. It has screw terminals on both ends. Each screw terminal has + and - holes.
Wire #
Color
From (start)
To (end)
Purpose
1
Red
Breadboard: free hole in VM row (same row as battery +)
Buck converter: IN+ screw terminal
Battery 8.4V into buck converter
2
Black
Breadboard: free hole in GND row (same row as battery -)
Buck converter: IN- screw terminal
Ground into buck converter
3
Dark Orange
Buck converter: OUT+ screw terminal
ESP32: VIN pin (M-F wire, female end on ESP32)
Regulated 5V to power ESP32
4
Black
Buck converter: OUT- screw terminal
Breadboard: free hole in GND row
Buck output ground back to common GND
Motors to TB6612FNG -- spliced wire ends into breadboard
Wire
From (Motors)
To (TB6612FNG)
Purpose
Yellow
Front Red + Rear Black
AO1
Motor output 1
Gray/White
Rear Red + Front Black
AO2
Motor output 2
Wiring Order
Ground first, signals in the middle, power last. Battery switch OFF until all wiring is done.
1
ESP32 GND → TB6612FNG GNDblack M-F wire
Common ground reference. Always wire this first.
2
Battery black (-) → TB6612FNG GNDbare black wire
Use a different GND pin than step 1. Now ESP32 and battery share a common ground through TB6612FNG.
3
ESP32 GPIO 27 → AIN1blue M-F wire
Direction control pin 1.
4
ESP32 GPIO 26 → AIN2green M-F wire
Direction control pin 2.
ESP32 3V3 → TB6612FNG VCCorange M-F wire
Powers the TB6612FNG logic (needs 2.7-5.5V, we give it 3.3V).
7
Spliced Wire A (Front Red + Rear Black) → AO1motor wire into breadboard
Motor output terminal 1. Strip and tin the wire end if it doesn't fit the breadboard hole.
8
Spliced Wire B (Rear Red + Front Black) → AO2motor wire into breadboard
Motor output terminal 2.
9
Battery red (+) → TB6612FNG VMbattery red wire
Motor power supply. This is live 8.4V.
Steps 10-13: Battery power for ESP32 (via buck converter)
Do these AFTER flashing your code via USB. Disconnect USB before connecting VIN.
10
Breadboard VM row (free hole) → Buck IN+ screw terminalred wire
Plug male end into a free hole in the same breadboard row where battery + already sits (the VM row).
Strip the other end, insert into the IN+ screw terminal, tighten with screwdriver.
11
Breadboard GND row (free hole) → Buck IN- screw terminalblack wire
Same idea -- tap from the GND row where battery - sits. Strip other end into IN- screw terminal.
12
Check display reads 5.0V. If not, adjust potentiometer.
Turn on battery. The buck converter display should light up. Turn the blue potentiometer screw with a small screwdriver until display shows 5.0.
Do this BEFORE connecting to ESP32.
13
Buck OUT+ → ESP32 VINdark orange M-F wire
Strip one end into the OUT+ screw terminal. Female end clips onto ESP32 VIN pin.
Buck OUT- → breadboard GND row (free hole)
black wire
Strip one end into OUT- screw terminal, other end into breadboard GND row.
ESP32 should boot and code starts running.
Motor Direction Control
Both motors move together (anti-parallel splice). Channel A controls both left-side wheels.
AIN1 (GPIO 27)
AIN2 (GPIO 26)
PWMA (GPIO 14)
Result
HIGH
LOW
0-255
Forward at speed
LOW
HIGH
0-255
Backward at speed
LOW
LOW
any
Coast (free-wheel)
HIGH
HIGH
any
Brake (locked stop)
Voltage Reference (Multimeter Debugging)
Battery ON, ESP32 on USB, no firmware flashed.
Set multimeter to DC voltage (20V range). Black probe = GND reference unless noted.
Power Rails -- confirms wiring is correct
Probe +
Probe -
Expected
If wrong
Battery red wire
Battery black wire
7.4 - 8.4V
Batteries dead or not in series
TB6612FNG VM pin
TB6612FNG GND pin
7.4 - 8.4V
Battery red wire not reaching VM, or GND not connected
TB6612FNG VCC pin
TB6612FNG GND pin
~3.3V
Orange wire loose, or ESP32 not powered via USB
ESP32 3V3 pin
ESP32 GND pin
~3.3V
ESP32 not powered -- check USB cable
Ground Continuity -- most critical check
Probe +
Probe -
Expected
If wrong
ESP32 GND pin
Battery black (-) wire
~0V
Grounds not linked. Both GND wires must reach TB6612FNG GND pins. This is the #1 failure.
Control Pins -- no firmware running, GPIOs are floating
Probe +
Probe - (GND)
Expected
Why
AIN1 (GPIO 27)
GND
~0 - 0.3V (floating)
GPIO defaults to INPUT mode at boot. High impedance. Not driving anything.
AIN2 (GPIO 26)
GND
~0 - 0.3V (floating)
Same -- no firmware setting it to OUTPUT
PWMA (GPIO 14)
GND
~0 - 0.3V (floating)
This is the critical one. PWMA = 0 means motor output is disabled regardless of AIN1/AIN2.
Motor Outputs -- should be dead without firmware
Probe +
Probe -
Expected
Why
AO1
GND
~0V
No valid control signal, driver outputs off
AO2
GND
~0V
Same
AO1
AO2
~0V
No voltage difference across motor terminals = wheels don't spin. This is expected without firmware.
Why nothing moves: Without firmware, all ESP32 GPIOs are in INPUT mode (high impedance).
AIN1, AIN2, and PWMA are effectively LOW. The TB6612FNG has no instructions to drive the motors.
The wiring can be 100% correct and you'll still see nothing until you flash code that sets
GPIO 27, 26, 14 to OUTPUT mode and drives them HIGH/LOW with PWM.
What voltages change AFTER flashing firmware
With test code running: AIN1=HIGH, AIN2=LOW, PWMA=255 (full speed forward)
Probe +
Probe -
Before firmware
After firmware
AIN1
GND
~0V
~3.3V (HIGH)
AIN2
GND
~0V
~0V (LOW)
PWMA
GND
~0V
~3.3V (PWM 255 = always HIGH)
AO1
AO2
~0V
~7.4-8.4V -- motors spin!
Important Notes
Double-check ground before power.
If ESP32 GND and battery GND are not connected through the TB6612FNG's common GND, the logic signals will be meaningless and you risk damaging the ESP32.
Battery polarity.
Reversing the battery (red to GND, black to VM) will destroy the TB6612FNG instantly. Verify with a multimeter before connecting step 9.
No STBY pin on this module.
Your TB6612FNG breakout shows NC (no connect) where STBY would be. This means STBY is tied HIGH internally. The driver is always active when powered. No extra wiring needed.
ESP32 power: two modes.Dev mode: ESP32 on USB (for flashing and serial monitor). Disconnect buck converter OUT+ from VIN.
Untethered mode: Unplug USB, buck converter feeds 5V to VIN. ESP32 runs from battery.
Do not connect USB and buck converter VIN simultaneously.
Set buck converter to 5V BEFORE connecting to ESP32.
Most buck converters (LM2596, MP1584) have a potentiometer. Connect battery IN+/IN-, then measure OUT+ with a multimeter. Adjust until it reads 5.0V. Only then connect OUT+ to ESP32 VIN. Sending 8.4V to VIN will fry the onboard regulator.
Power chain (battery mode).
Battery 8.4V splits two ways: (1) directly to TB6612FNG VM for motors, (2) through buck converter to 5V, then to ESP32 VIN. ESP32's onboard regulator steps 5V down to 3.3V, which feeds TB6612FNG VCC via the orange wire.
No serial monitor in battery mode.
Without USB, you lose debug output. Flash your code while on USB first, verify it works, then switch to battery. The code runs automatically on boot.
Spliced motor wires in breadboard.
The spliced wire ends are likely stranded copper. If they don't fit breadboard holes cleanly, strip 5mm, twist tight, and tin with solder. Or crimp a male DuPont pin onto each end.
Test Commands
Flash and test each side independently before combining.