Directly wiring an inductive motor load to a Raspberry Pi GPIO pin will instantly destroy the SoC. The Pi’s GPIO headers output 3.3V logic at a maximum of 16mA per pin (with a strict 50mA bank limit). Even a micro-vibration motor draws 20mA to 50mA, and standard robot drive motors pull 500mA to 3A under load. Effective raspberry pi motor control requires an intermediary driver IC that translates low-current 3.3V logic signals into high-current motor power, while protecting the Pi from inductive back-EMF spikes.
This guide cuts through the outdated tutorials still recommending the highly inefficient L298N driver. We will map the correct motor topology to your specific load profile, walk through a real-world torque sizing calculation, and detail the exact terminal wiring for the modern standard: the TB6612FNG MOSFET H-bridge.
The Motor Selection Matrix for Raspberry Pi Projects
Choosing a motor is not just about voltage; it is about matching the torque curve to your mechanical load and ensuring the Pi can generate the required control signals. Below is the definitive selection matrix for embedded robotics and automation in 2026.
| Motor Type | Torque Curve Profile | Pi Control Needs | Required Driver IC | Avg Cost (USD) |
|---|---|---|---|---|
| Brushed DC (BDC) | Max torque at stall (0 RPM); drops linearly as speed increases. | 1x PWM pin for speed, 2x GPIO for direction (H-bridge). | TB6612FNG, DRV8833, or DRV8871. | $3 - $15 |
| Brushless DC (BLDC) | Flat, high torque across a wide RPM band; requires commutation. | 3x PWM pins (120° phase shift) or UART/CAN for smart ESCs. | 3-Phase ESC (e.g., ODrive, SimpleFOC) or dedicated 3-phase bridge. | $25 - $80 |
| Bipolar Stepper | Max torque at holding (0 RPM); drops sharply at high speeds. | Step/Dir pulses (2 pins) or 4x sequential GPIO pulsing. | TMC2209 (UART/QuietStep), A4988, or DRV8825. | $12 - $35 |
| RC Servo | High holding torque at specific angular positions; not for continuous rotation. | 1x PWM pin at exactly 50Hz (20ms period, 1-2ms pulse width). | PCA9685 (I2C 16-channel PWM board) to offload Pi CPU jitter. | $8 - $25 |
Choose Brushed DC when you need simple, continuous rotation for wheeled rovers or conveyor belts where exact positioning is handled by external encoders or doesn't matter.
Choose Steppers when you need open-loop precise positioning (e.g., 3D printers, CNC plotters, camera sliders) and the load will not exceed the motor's holding torque.
Choose BLDC for high-speed, high-efficiency applications like drones, gimbal stabilizers, or fast robotic arms where weight-to-torque ratio is critical.
Choose Servos for low-speed, high-torque angular articulation (e.g., robotic joints, pan/tilt camera mounts) under 180 degrees of travel.
Sizing Your Drive: A Worked Load Example
The most common mistake in Raspberry Pi robotics is sizing a motor to the exact calculated steady-state load. Motors must overcome static friction, startup inertia, and unexpected inclines. The golden rule of thumb: calculate your peak theoretical load, then multiply by a 2x to 3x safety factor to determine your required stall torque.
Let’s size the drive motors for a 5kg (50N) 2-wheel-drive (2WD) autonomous rover with 65mm diameter wheels, designed to climb a 15-degree incline.
1. Calculate the Forces
- Gravity component on slope: Mass × g × sin(θ) = 5kg × 9.81 × sin(15°) = 12.69 N
- Rolling resistance: Mass × g × cos(θ) × Crr (assume 0.02 for rubber on concrete) = 5 × 9.81 × cos(15°) × 0.02 = 0.95 N
- Acceleration force: Mass × desired acceleration (assume 0.5 m/s²) = 5kg × 0.5 = 2.50 N
- Total Peak Force: 12.69 + 0.95 + 2.50 = 16.14 N
2. Convert to Torque per Motor
Divide the total force by the two drive wheels: 16.14 N / 2 = 8.07 N per wheel.
The wheel radius is 32.5mm (0.0325m). Torque = Force × Radius.
8.07 N × 0.0325 m = 0.262 Nm (or roughly 2.67 kg-cm) per motor just to meet the physical requirement.
3. Apply the Safety Factor
Multiply by 2x to account for voltage sag, unmodeled friction, and surface anomalies: 2.67 kg-cm × 2 = 5.34 kg-cm required stall torque per motor.
Many beginner kits include the yellow plastic TT gearmotors. These motors have a typical stall torque of only 0.8 kg-cm at 3V-6V. If you use them on this 5kg rover, they will stall immediately on the incline, draw their maximum stall current (approx 1.5A), overheat, and likely brown out your Pi if they share a poorly regulated 5V rail. For this load, you must purchase 12V metal-gear planetary DC motors rated for at least 6 kg-cm stall torque (typically $12-$18 each from suppliers like Pololu or GoBilda).
Wiring the TB6612FNG: Terminal ID and Pi GPIO Mapping
For brushed DC motors under 1.2A continuous (3.2A peak), the TB6612FNG dual H-bridge is the undisputed standard. Unlike the ancient L298N BJT-based driver which drops up to 2.0V as waste heat, the TB6612FNG uses MOSFETs, dropping only ~0.5V. This means your 6V motors actually get 5.5V, not 4V.
Below is the exact terminal identification and wiring map for connecting a TB6612FNG breakout board to a Raspberry Pi 5.
| TB6612FNG Pin | Function | Raspberry Pi Connection | Notes & Warnings |
|---|---|---|---|
| VM | Motor Voltage Supply | External Battery Pack (+) | Do NOT connect to Pi 5V pin. Use a dedicated 6V-12V LiPo or AA pack. |
| VCC | Logic Voltage Supply | Pi Pin 1 (3.3V) | Crucial: The Pi is a 3.3V logic device. Feeding 5V to VCC can damage the Pi's GPIO bank. |
| GND | Common Ground | Pin 6 (GND) + Battery (-) | The Pi GND and Battery GND MUST be tied together for the logic signals to register. |
| STBY | Standby Mode | Pi 3.3V (Direct) or GPIO | Pull HIGH to enable. If you don't need software standby, wire directly to VCC/3.3V. |
| PWMA / PWMB | Speed Control (PWM) | GPIO 12 (PWM0) / GPIO 13 (PWM1) | Use hardware PWM pins on the Pi for smooth speed control without CPU jitter. |
| AIN1 / AIN2 | Motor A Direction | GPIO 5 / GPIO 6 | Set one HIGH and one LOW for forward/reverse. Both LOW = coast, both HIGH = brake. |
| BIN1 / BIN2 | Motor B Direction | GPIO 16 / GPIO 26 | Same logic as Motor A. |
| AO1 / AO2 | Motor A Output | Motor A Terminals | Polarity dictates forward direction. Swap wires if the motor spins backward. |
Python Control Snippet (gpiozero)
Using the gpiozero library, you can abstract the H-bridge logic cleanly. Ensure your PWM pins are correctly assigned to hardware PWM channels to avoid audible whining from the motors.
from gpiozero import Motor, PWMOutputDevice
from time import sleep
# Define PWM devices on hardware PWM pins (GPIO 12 and 13)
pwm_a = PWMOutputDevice(12, frequency=1000)
pwm_b = PWMOutputDevice(13, frequency=1000)
# Define Motor objects (forward_pin, backward_pin, enable_pin/pwm)
motor_left = Motor(forward=5, backward=6, enable=pwm_a)
motor_right = Motor(forward=16, backward=26, enable=pwm_b)
# Drive forward at 60% speed
motor_left.forward(0.6)
motor_right.forward(0.6)
sleep(2)
motor_left.stop()
motor_right.stop()
Failure Signatures: Diagnosing Hum, Overheat, and Stall
When a motor system fails, the physical symptoms tell you exactly what is wrong electrically. Do not blindly swap parts; read the failure signature.
1. The "Hum" or Audible Whine
- In Brushed DC: A high-pitched whine means your PWM frequency is set in the audible range (e.g., 500Hz). Fix: Increase the PWM frequency in your Python/C++ code to at least 20kHz, which is above human hearing and stops the motor coils from acting as speakers.
- In Steppers: A loud buzzing or humming without movement usually indicates a mismatched coil pairing (e.g., wiring A+ and B+ to the same coil) or the current limit potentiometer on the driver (like an A4988) is set too low to overcome the rotor's cogging torque. Fix: Verify coil pairs with a multimeter (shorted pins belong to the same coil) and adjust the Vref on the driver.
2. Overheat and Thermal Shutdown
If your driver IC becomes too hot to touch (>85°C) and the motor randomly cuts out, you are hitting the silicon's thermal shutdown threshold. The TB6612FNG is rated for 1.2A continuous per channel. If your motor draws 1.5A continuous, the chip will overheat. Fix: Add a small aluminum heatsink to the IC, ensure adequate airflow, or step up to a higher-current driver like the DRV8871 (3.6A continuous) or a discrete MOSFET H-bridge. Never rely on the L298N for high current; its massive voltage drop turns electrical energy directly into heat.
3. Stall and Pi Brownout
When a DC motor stalls (mechanically blocked), it stops generating back-EMF. The current draw instantly spikes to the motor's stall current, which can be 5 to 10 times the running current. If your motor power supply and Pi power supply share the same battery pack without adequate decoupling, this massive current draw will cause the battery voltage to sag. If the voltage drops below 4.6V, the Pi's brownout detector will trigger, causing the Pi to reboot or drop USB peripherals. Fix: Always use a dedicated, high-C-rating battery pack for motors, or place a large electrolytic capacitor (e.g., 1000µF 16V) across the motor VM and GND terminals to absorb transient current spikes.






