L298N dual motor driver with ESP32
Supply 5 V
Bus GPIO
Pins and ESP32 wiring
| Pin | Role | ESP32 pin | Notes |
|---|---|---|---|
| ENA | Input (the ESP32 drives it) | D25 | Motor A speed (PWM). Remove the jumper to use it |
| IN1 | Input (the ESP32 drives it) | D26 | Motor A direction |
| IN2 | Input (the ESP32 drives it) | D27 | Motor A direction |
| IN3 | Input (the ESP32 drives it) | D32 | Motor B direction |
| IN4 | Input (the ESP32 drives it) | D33 | Motor B direction |
| ENB | Input (the ESP32 drives it) | D23 | Motor B speed (PWM). Remove the jumper to use it |
| 12V | Not wired to the ESP32 | — | Motor supply 5 to 35 V from a separate supply |
| GND | Ground | GND | Share it with the motor supply and the ESP32 GND |
| 5V | Not wired to the ESP32 | — | 5 V output of the on-board regulator (jumper on, supply up to 12 V) |
| OUT1 | Not wired to the ESP32 | — | Motor A |
| OUT2 | Not wired to the ESP32 | — | Motor A |
| OUT3 | Not wired to the ESP32 | — | Motor B |
| OUT4 | Not wired to the ESP32 | — | Motor B |
Suggested wiring for the 30-pin ESP32 DevKit, avoiding flash, input-only and strapping pins. BoardPilot checks it for you as you wire.
This module is sold for 5 V. Its outputs may be 5 V: use a level shifter or a voltage divider on ESP32 inputs.
Good to know
- The L298 loses about 2 to 3 V inside: a motor on a 6 V supply gets roughly 4 V. Connect the driver’s GND to the board’s GND. (ST L298 datasheet, Total drop (source + sink saturation voltage))
Sources
- ST L298 datasheet, Logic inputs: HIGH level from 2.3 V; about 2 V drop across the bridge
Try it in 3D in BoardPilot
L298N dual motor driver on other boards: wiring and code
Arduino Mega 2560 R3 Arduino Nano Arduino Uno R3 WeAct Black Pill STM32F411CE ESP32-C3-DevKitM-1 ESP32-S3-DevKitC-1 Nordic nRF52840 DK NUCLEO-F401RE Raspberry Pi Pico 2 Raspberry Pi Pico W Raspberry Pi Pico Teensy 4.1
Learn the basics
Lesson: GPIO: pins in and out Lesson: Hardware basics for software developers GPIO Level shifter Logic level (HIGH and LOW)
Related parts
18650 Li-ion cell in holder28BYJ-48 stepper + ULN2003 driver433 MHz transmitter (FS1000A)74HC595 shift registerA4988 stepper driverActive buzzer
Part data: CC BY 4.0, free to reuse with credit to BoardPilot.