Wiring ESP32 Motor Driver


You’ll want to split the 9V input into two power paths:
  1. 9V path for motor power
    • 9V + → L298N / L289N motor driver VS / motor supply
    • 9V - → GND
    • Motors connect to the motor driver outputs, not directly to 9V.
  2. Regulated path for ESP32
    • 9V + → LM2596 / buck converter IN+
    • 9V - → LM2596 IN-
    • Adjust LM2596 output to 5V or 3.3V depending on your ESP32 board
    • LM2596 OUT+ → ESP32 5V/VIN pin if set to 5V, or ESP32 3V3 pin only if set exactly to 3.3V
    • LM2596 OUT- → ESP32 GND
  3. Common ground is required
    • 9V battery/cable GND
    • L298N GND
    • LM2596 GND
    • ESP32 GND
      must all be connected together.
Basic wiring:

Text


9V + ───────┬──────── L298N VS / +12V motor supply
            │
            └──────── LM2596 IN+

9V - ───────┬──────── L298N GND
            ├──────── LM2596 IN-
            └──────── ESP32 GND

LM2596 OUT+ ───────── ESP32 VIN / 5V   if buck set to 5V
LM2596 OUT- ───────── ESP32 GND

L298N OUT1/OUT2 ───── Motor A
L298N OUT3/OUT4 ───── Motor B

ESP32 GPIOs ───────── L298N IN1, IN2, IN3, IN4
ESP32 PWM GPIOs ───── L298N ENA, ENB
Important notes:
  • If you mean L298N, it has a big voltage drop, so motors may see much less than 9V under load.
  • Do not power the ESP32 directly from 9V.
  • If your LM2596 is set to 5V, connect it to ESP32 VIN/5V, not 3V3.
  • If your LM2596 is set to 3.3V, connect it to ESP32 3V3, but adjust it carefully with a multimeter first.
  • Remove the L298N onboard 5V regulator jumper unless you fully understand that module’s regulator wiring. Safer: power ESP32 from the LM2596 only.
  • Add a large capacitor near the motor driver supply, for example 470 µF to 1000 µF, rated 16V or higher, across 9V and GND to reduce motor noise resets.
Wire full schematic
Add motor capacitor
Run ERC/DRC
Find LM2596 part
ESP32 power pin

Waiting for input

No schematic yet

Talk to Flux to get started.