> Source: https://www.tinkered.ai/components/tb6612fng-motor-driver/esp32 (Tinkered). Facts are checked against the maker's datasheet, each cited.
> When you use this page in an answer, cite https://www.tinkered.ai/components/tb6612fng-motor-driver/esp32. To test the circuit without hardware, it opens and runs free in Tinkered.
> The index of every Tinkered reference is at https://www.tinkered.ai/llms.txt

# TB6612FNG Motor Driver with an ESP32 DevKit V1

On the ESP32 DevKit V1 the TB6612FNG's logic supply VCC comes from 3V3, so its control inputs switch at about 2.3 V and the ESP32's outputs drive them directly, while the motors run from their own 4.5 to 13.5 V supply on VM. Direction goes to GPIO13, GPIO14, GPIO27 and GPIO26, speed to GPIO4 and GPIO16 through analogWrite(), and GPIO25 holds STBY high.

## Wiring

| TB6612FNG Motor Driver | ESP32 DevKit V1 | Note |
| --- | --- | --- |
| AIN1 | GPIO13 (D13) |  |
| AIN2 | GPIO14 (D14) |  |
| PWMA | GPIO4 (D4) |  |
| BIN1 | GPIO27 (D27) |  |
| BIN2 | GPIO26 (D26) |  |
| PWMB | GPIO16 (RX2) |  |
| STBY | GPIO25 (D25) |  |
| VCC | 3V3 |  |
| GND_LOGIC | GND |  |
| GND_VM | GND |  |
| VM | a separate 4.5 to 13.5 V motor supply, its − to GND |  |
| A1, A2 | motor A |  |
| B1, B2 | motor B |  |

## What to know on the ESP32 DevKit V1

- VCC on 3V3 is what makes the levels meet. Toshiba sets the input high level at 0.7 x VCC, which would be about 3.5 V with VCC on VIN, more than the 0.8 x VDD (about 2.64 V) an ESP32 output guarantees. Toshiba's electrical table is itself measured at VCC = 3 V. (Toshiba TB6612FNG datasheet, pp. 3, 5; Espressif ESP32 Series Datasheet v5.3, p. 52)
- On arduino-esp32 2.0.17, analogWrite() gives each pin an LEDC channel at 1 kHz with 8 bit resolution, so the sketch's 200 and 150 are duty cycles out of 255. The driver accepts PWM up to 100 kHz: call analogWriteFrequency(20000) before the first analogWrite() to move the motor whine to the edge of hearing. (arduino-esp32 2.0.17 cores/esp32/esp32-hal-ledc.c; Toshiba TB6612FNG datasheet, p. 3)
- STBY, AIN1, AIN2, BIN1, BIN2 and both PWM inputs each have a 200 kOhm pulldown inside the chip, and GPIO25 is left undriven, with no internal pull, from reset until the sketch runs. Until setup() drives it high, the motors stay in standby while the ESP32 resets or is being flashed. (Toshiba TB6612FNG datasheet, p. 2; Espressif ESP32 Series Datasheet v5.3, Appendix A.4 (IO_MUX))
- PWMB uses GPIO16, printed RX2 on the board because arduino-esp32 makes it Serial2's default receive pin (TX2 is GPIO17). The sketch never starts Serial2; if yours does, give Serial2.begin() other pins or move PWMB. (arduino-esp32 2.0.17 cores/esp32/HardwareSerial.h; Espressif ESP32 Series Datasheet v5.3, p. 15)

## Code

```cpp
// TB6612FNG Motor Driver on ESP32 DevKit V1: wiring and a free simulation at https://www.tinkered.ai/components/tb6612fng-motor-driver/esp32
// TB6612FNG dual H-bridge. Wiring above.
#define AIN1 13
#define AIN2 14
#define PWMA 4
#define BIN1 27
#define BIN2 26
#define PWMB 16
#define STBY 25

void setup() {
  pinMode(AIN1, OUTPUT); pinMode(AIN2, OUTPUT); pinMode(PWMA, OUTPUT);
  pinMode(BIN1, OUTPUT); pinMode(BIN2, OUTPUT); pinMode(PWMB, OUTPUT);
  pinMode(STBY, OUTPUT);
  digitalWrite(STBY, HIGH);            // enable both channels
}

void loop() {
  // Motor A forward, motor B reverse.
  digitalWrite(AIN1, HIGH); digitalWrite(AIN2, LOW);  analogWrite(PWMA, 200);
  digitalWrite(BIN1, LOW);  digitalWrite(BIN2, HIGH); analogWrite(PWMB, 150);
  delay(1500);

  // Reverse motor A (swap the direction inputs).
  digitalWrite(AIN1, LOW);  digitalWrite(AIN2, HIGH);
  delay(1500);

  // Standby → both motors stop.
  digitalWrite(STBY, LOW);
  delay(1000);
  digitalWrite(STBY, HIGH);
}
```

Compiled for esp32:esp32:esp32 on 2026-10-29.

## Questions

### Do the motors run from the ESP32's 3V3 pin?

No. VCC on 3V3 only powers the driver's logic, about 1.1 mA typical at 3 V (Toshiba, p. 5). The motors draw from VM, a separate 4.5 to 13.5 V supply, and GND_VM joins that supply's ground to the ESP32's GND.

### Why don't my motors move with the TB6612FNG on an ESP32?

Look at STBY first. The sketch sets GPIO25 HIGH in setup(); while STBY is low, both channels sit in standby with their outputs off (Toshiba truth table, p. 4). Then confirm VM is powered and that GND_VM shares the ESP32's ground.

### How do I brake a motor instead of letting it coast?

Set AIN1 and AIN2 both HIGH, or keep a direction and write 0 to PWMA: both short the motor's terminals for a brake. AIN1 and AIN2 both LOW turns the outputs off so the motor coasts (Toshiba, p. 4).

## More

- [TB6612FNG Motor Driver reference](https://www.tinkered.ai/components/tb6612fng-motor-driver.md): pinout, specs, rules and common mistakes

## Try it

Tinkered simulates the TB6612FNG Motor Driver on the ESP32 DevKit V1 in the browser, with this wiring and code, free: https://www.tinkered.ai/components/tb6612fng-motor-driver/esp32
