To connect a Raspberry Pi to an L298N motor driver, you route 3.3V logic from the Pi's GPIO pins (BCM 17, 27, and 22) to the driver's IN1, IN2, and ENA inputs, while sharing a common ground between the Pi's GND (Pin 6) and the driver's GND terminal. The 12V motor power is sourced from an external battery and kept completely isolated from the Pi's sensitive 3.3V logic rail. This guide traces the physical wiring diagram node-by-node, maps the exact terminals, and shows you how to verify the circuit with a multimeter before applying power.

Decoding the Diagram: Symbols and Physical Terminals

Before stripping wires, you need to translate standard schematic symbols to the physical hardware sitting on your bench. Wiring diagrams for motor controllers often use generic labels that don't perfectly match the silkscreen on cheap import modules.

On the Raspberry Pi 40-Pin Header:
The physical header uses a 2x20 grid. Pin 1 is always the 3.3V supply, located at the top-left when the USB ports face you. Pin 2 is the 5V supply. Ground pins are scattered throughout (Pins 6, 9, 14, 20, 25, 30, 34, 39). In diagrams, VCC or 3V3 refers to Pin 1, while 5V refers to Pin 2. GND is the universal signal ground. For this circuit, we only use the 3.3V logic pins and GND; we do not draw power from the Pi's 5V rail to drive the motor.

On the L298N Motor Driver Module:
The L298N board features two distinct connection zones. The large blue or green screw terminals handle high-current power: 12V (or VCC/VIN), GND, and 5V (which is an output from the onboard 7805 regulator, not an input). The male pin headers handle low-current logic: ENA (PWM speed control for Motor A), IN1 and IN2 (direction control for Motor A), and the corresponding ENB, IN3, IN4 for Motor B.

Diagram Symbol Note: If your schematic shows a jumper across the "5V" and "GND" pins on the L298N, it means the board expects a >12V input and will use its internal linear regulator to generate 5V. For a 12V battery setup, remove this jumper. We will not use the L298N's 5V output to power the Raspberry Pi, as the 7805 regulator cannot supply the 1.5A+ transient current spikes the Pi requires without severe voltage sag.

The Pin Mapping and Power Specification Table

The following table maps the exact physical pins on the Raspberry Pi to the L298N terminals. This assumes you are controlling a single 12V DC motor connected to the OUT1 and OUT2 terminals. Use 22 AWG stranded wire for the logic connections and 18 AWG stranded wire for the 12V power and motor terminals to handle the current without excessive voltage drop.

Pi Pin (Physical) Pi Pin (BCM) L298N Terminal Wire Color Voltage Level Function
Pin 6 GND GND (Screw) Black 0V Common Logic & Power Ground
Pin 11 GPIO 17 IN1 (Header) Green 3.3V Logic Motor A Direction 1 (Forward)
Pin 13 GPIO 27 IN2 (Header) Blue 3.3V Logic Motor A Direction 2 (Reverse)
Pin 15 GPIO 22 ENA (Header) Yellow 3.3V PWM Motor A Speed Control
N/A (Battery +) N/A 12V (Screw) Red 12V DC Motor Power Source
N/A (Battery -) N/A GND (Screw) Black 0V Motor Power Return

Reference: For the official Raspberry Pi pinout and BCM mapping, consult the Raspberry Pi Hardware Documentation. For L298N logic thresholds and internal H-bridge schematics, refer to the STMicroelectronics L298 Datasheet.

Node-by-Node Trace: Source to Load and Ground Paths

A wiring diagram is useless if you don't understand the flow of electrons. Let's trace the circuit from the power source, through the driver, to the load, and finally establish the critical ground return.

1. The High-Current Power Path (Source to Load)
Current originates at the positive terminal of your 12V battery (a 12V LiFePO4 or sealed lead-acid pack). It travels through an 18 AWG red wire, optionally passing through a 10A inline blade fuse for short-circuit protection, and terminates at the 12V screw terminal on the L298N. Inside the module, this 12V rail feeds the internal dual full-bridge driver. When the Pi sends a HIGH signal to IN1 and a PWM signal to ENA, the H-bridge switches close, routing the 12V out through the OUT1 screw terminal, through the DC motor windings (the load), and returning via the OUT2 screw terminal.

Polarity Hazard: The L298N module has a reverse-polarity protection diode on the 12V input, but it is only rated for low current. If you accidentally swap the red and black wires on the 12V screw terminal, the diode will short the battery, potentially melting the trace or causing a fire. Always double-check battery polarity with a meter before tightening the screw terminal.

2. The Logic Control Path
The Raspberry Pi operates at 3.3V logic. The L298N's logic inputs (IN1, IN2, ENA) require a minimum of 2.3V to register a "HIGH" state. Therefore, the Pi's 3.3V GPIO pins can drive the L298N directly without a logic level shifter. The 3.3V signals travel from BCM 17, 27, and 22 through 22 AWG jumper wires to the male headers on the driver board, commanding the optocouplers and logic gates that switch the high-power H-bridge transistors.

3. The Equipotential Ground Path (Critical)
The most common reason this circuit fails—resulting in the motor stuttering or the Pi rebooting—is a floating or high-resistance ground. The 12V battery negative terminal must connect to the L298N GND screw terminal. Crucially, a second wire must run from that exact same GND screw terminal (or the adjacent GND header pin) to Pin 6 (GND) on the Raspberry Pi. This establishes equipotential bonding between the Pi's logic ground and the motor driver's power ground. Without this shared reference point, the Pi's 3.3V "HIGH" signal has no baseline to compare against, and the L298N will read it as random noise.

Verifying Your Connections with a Multimeter

Never apply power to the Raspberry Pi or the 12V battery until you have verified the physical wiring with a digital multimeter (DMM). Set your DMM to the appropriate modes and follow this three-step verification sequence.

Step 1: Ground Continuity Check (DMM set to Continuity / Ohms)
With all power disconnected, place the black probe on the Raspberry Pi's Pin 6 (GND) and the red probe on the negative terminal of the 12V battery. The meter should read less than 1.0 ohm (ideally < 0.2 ohms) and emit a continuous beep. If the reading is "OL" (Open Loop) or fluctuates, your ground wire is broken or not fully seated in the L298N screw terminal. Do not proceed until this reads < 1 ohm.

Step 2: Logic Isolation Check (DMM set to Continuity)
Place one probe on the L298N's 12V screw terminal and the other probe on any of the Pi's GPIO wires (IN1, IN2, or ENA). The meter must read "OL" (infinite resistance). If you get a continuity beep here, you have a short circuit that will instantly feed 12V into the Pi's 3.3V GPIO pin, permanently destroying the Broadcom SoC. Check your wire routing for stripped insulation touching the wrong terminals.

Step 3: Live Voltage Verification (DMM set to DC Volts, 20V range)
Power on the Raspberry Pi via its official USB-C power supply. Do not connect the 12V battery yet. Using a Python script or the raspi-gpio command line tool, set GPIO 17 (IN1) to HIGH. Place the black probe on the Pi's Pin 6 (GND) and the red probe on the L298N's IN1 header pin. You should read between 3.25V and 3.35V. Next, set GPIO 17 to LOW; the meter should drop to < 0.1V. Repeat for IN2 and ENA. Once logic levels are confirmed, connect the 12V battery and measure across the OUT1 and OUT2 screw terminals while the motor is commanded to run; you should see ~11.5V to 12V under load.

By tracing the diagram node-by-node and verifying the ground and logic paths with a meter, you eliminate the guesswork that leads to bricked microcontrollers and melted motor drivers. The L298N is a robust, forgiving chip, but it relies entirely on a clean, shared ground reference to translate the Pi's delicate 3.3V commands into heavy 12V mechanical work.