Controlling a DC motor with TB6612FNG on ESP32

Hi everybody, I’m a noob both here and with electronics in general. I’m trying to get a DC motor working with my ESP32, using a motor driver board TB6612FNG. It doesn’t do anything after I upload the sketch.

Here’s how I hooked it up:
VM → 9v battery positive
VCC → 3.3v output pin 1 from ESP32
GND → 9v battery negative
A01, A02 → DC motor
STBY → GPIO27 (11)
AIN1 → GPIO14 (12)
AIN2 → GPIO12 (13)
PWMA → GPIO13 (15)
GND 1, GND 2 → GND (14)

I copy/pasted this sketch without modifying it:

I was able to measure 3.3 volts on the TB6612 VCC, and 8.9v from the VM. But the motor doesn’t move (if I hook up the battery directly to the motor is does). The Serial Monitor prints the Loop message so I know the sketch is running on the ESP32 properly.

Any ideas? This is driving me nuts!

Thanks in advance,


  1. Are you using a motor driver board or directly wiring to the TB6612?
  2. A picture of your setup may help.
  3. Schematic?
  4. I assume the code compiled with no errors or warnings?

I will take a look.

In the mean time I would comment everything out of the loop except:

void loop()
Serial.printf(“Loop: %d\n”, millis());
// 500ms forwards, 500);

… and see if the motor will run one direction and speed?

Hi Don, thanks for replying. Happy Friday! Sorry for taking so long. I looked for a good breadboard layout solution and found that Tinkercad has one, so I whipped up a wiring diagram.

Firstly, to answer your questions:

  1. Are you using a motor driver board or directly wiring to the TB6612?

The TB6612 is the motor driver board and I’m wiring up the ESP32 directly to it.

  1. A picture of your setup may help.

The four sets of 8-pin headers represent the 32-pin ESP32. The two lower sets represent the TB6612FNG board. I couldn’t figure out how to overlay the pics in Tinkercad so left it as-is.

The TB6612FNG pin layout in the wiring diagram is as follows:
Left Side:
1 - PWMA
2 - AIN2
3 - AIN1
4 - STBY
8 - GND

Right Side:
9 - VM
10 - VCC
11 - AO1
12 - A02
16 - GND

  1. Schematic?
    I included a wiring diagram pic

  2. I assume the code compiled with no errors or warnings?
    No errors or warnings.

The exact TB6612FNG is this one in Amazon: Teyleten Robot Motor Driver Module 1.2A Peak 3.2A TB6612FNG (Pack of 3): Home Improvement

The exact ESP32 is this one in Amazon:

I also simplified the code in the loop() method as you suggested and no difference. The motor doesn’t vibrate or anything.

Hopefully this helps. Thanks again Don!


I took a look and drew up a schematic of what I interpret your setup to be.
Let me know if I got it right.

I found nothing obvious…

I would try these things:

  • Disconnect Standby from the motor controller. I think that will enable it. See if that allows the motors to turn on. In any case leave it off for now.

  • If that did not work I would run the sketch and use a meter to read the state of :

    • AIN1-
    • AIN2 -

From this table we can see what state we are telling the controller to be in.

AIN1 AIN2 State
1 1 short brake
0 1 stop
1 0 CW
0 1 CCW

I am not familiar with the library you are using.
As an alternate there is one over at Sparkfun for a similar board. Of course you will have to modify it for the pins you are using.

1 Like

Hi Don, thanks for the reply and for your time on this. When I get some time over this weekend I’ll try out your suggestions. I had heard from somewhere that STBY needed to be HIGH in order for it to work, and the code I use asks for the STBY pin in the class constructor. But it won’t hurt to try disconnecting it.

I also saw someone in a different forum talk about it working after they soldered the header pins, which I haven’t done yet. I just placed the headers in the breadboard and placed the TB6612 on top without soldering. Maybe soldering will do the trick. :smiley:

Your schematic is exactly how I have it; I’m glad to see my diagram was readable. lol

I did try the code from SparkFun that you suggested and since I couldn’t get it to work decided to use this other one since it was a lot simpler. Needless to say, it didn’t work either.

Thanks for your help and I hope you have a great weekend!


OMG I missed this… you definitely need to solder the headers in place :)!

1 Like

Hi Don, sorry for the long delay. I accidentally fried my ESP32; I’m not a very good solderer. lol So I had to wait for the new one to arrive from Amazon. It worked! (after I cleaned up my bad soldering job :smiley:)

Thanks again for your time on this; it was greatly appreciated!


1 Like

Its the little things that kill ya sometimes

1 Like