ESP32 Dual H Bridge Breakout Board

This project is for an ESP32 Breakout board that was designed to be the brains of your next robot. The features of this board are;

  • Can accommodate any ESP32 dev kit that has two rows of up to twenty pins on one inch centers.
  • A place to mount a TB6612FNG dual H bridge DC motor controller daughter board.
  • A two screw terminal block for each motor connection.
  • A two screw terminal block and a set of five header pins for Vin & Gnd
  • Two rows of twenty GPIO breakout pins.
  • Headers for two HC-SR04 Sonar sensors, with voltage dividers on the Echo output.
  • A header for connecting to a tri-color, common anode, LED with limiting resistors.
  • On board 5V, 1A voltage regulator with five header pins for 5V & Gnd.
  • Four sets of headers for I2C connections with 3.3V & Gnd for each connection.
  • All components mount on one side of the circuit board.

The physical size of the board is 90mm x 56mm, two sided. This puts it well within the 100mm x 100mm size limits for most board makers low cost prototypes.

All of the files required to make one of these boards can be found on github here.

The board was designed around the DOIT ESP32 DEVKIT V1 which has two rows of eighteen pins each. Easily cut traces on the backside of the board allow you to separate the dedicated 5V, Gnd and 3.3V pins from their respective buses. Then you can use the pins in these locations as GPIO and using jumpers, connect the 5V, Gnd and 3.3V buses to the appropriate pins on the ESP32 dev kit that you are using.

Two rows of twenty holes are provided for mounting the ESP dev kit. I recommend that you buy female socket strips and solder them into the holes. This way you can remove the ESP32 dev kit and replace it with another at any time. Also, using the socket strips provides plenty of clearance for the parts mounted under the dev kit. I like to buy forty pin header and socket strips and then cut them down to size. This helps to reduce costs. You cannot cut the female socket strips between two sockets, you must 'burn' a socket to cut them down. In other words, a forty pin female socket strip cannot be cut into two twenty pin strips. A forty pin female socket strip can be cut into a twenty pin strip and a nineteen pin strip.

Step 1: TB6612FNG Dual H Bridge

The TB6612FNG is a dual H bridge, motor controller that can drive one stepper motor or two DC hobby motors (not brushless motors). It is ideal for driving the small, inexpensive, geared motors that are readily available. The breakout board has a place to mount a daughter board that has the TB6612FNG. The TB6612FNG board that I chose to use is available from several places; Sparkfun (p/n ROB-14451, Mouser and Digikey also sell the Sparkfun board), Pololu (p/n 713), EBay, Aliexpress and Gearbest. Prices vary from about one dollar to five dollars.

Each DC motor driver uses three GPIO pins. Two GPIO pins determine motor state; forward, reverse, coast and brake. The third GPIO pin is PWM to control the motor speed. A seventh GPIO pin drives the STBY pin. The control signals for the TB6612FNG are hard-wired to ESP32 GPIO breakout pins. Which GPIO pins are used is determined by the flavor of ESP32 Dev Kit that you use. The hard-wired pins were carefully selected so that they should align with GPIO PWM and Output pins on most ESP32 Dev Kits.

The motors are connected using two, two pin screw terminal blocks labeled Motor A and Motor B. One on each side of the breakout board. Power for the motors is brought in by either a two pin screw terminal block or a set of male headers on one end of the breakout board, labeled Vin. Vin can be any DC voltage from 6V to 12V. A 5V, 1A voltage regulator converts the Vin voltage to 5V to power the Sonar sensors.

The DOIT Dev KIT comes in two sizes, 30 pins (15 on a side) and 36 pins (18 on a side). I have listed the connections for both dev kits below.

30 pin dev kit - 36 pin dev kit

AIN1 - 25 - 14 - direction control for motor A

AIN2 - 26 - 12 - direction control for motor A

PWMA - 27 - 13 - speed control for motor A

STBY - 33 - 27 - stops both motors

BIN1 - 16 - 15 - direction control for motor B

BIN2 - 17 - 2 - direction control for motor B

PWMB - 5 - 4 - speed control for motor B

Step 2: GPIO Pins

The board has two sets of twenty pin headers for GPIO breakout. Each set of GPIO headers includes twenty pins for 3.3V and twenty pins for Gnd. The 3.3V pins are located between the GPIO pins and the Gnd pins. This configuration reduces the possibility that something blows up if it is plugged in backwards. Almost every thing that you want to connect to a GPIO pin requires either a 3.3V or Gnd connection or both. The triple row configuration means that you always have a power and Gnd pin for every connection.

If you use an ESP32 dev kit other than the DOIT Dev Kit it may have Vin, 3.3V and Gnd pins in locations different from the DOIT Dev Kit. The breakout board has easily cut traces on the backside that can be cut to isolate the Vin, 3.3V and Gnd pins from the respective buses. You can then use jumper wires to connect the Vin, 3.3V and Gnd pins of your ESP32 Dev Kit to the proper buses. The 3.3V pins can be connected using standard two pin shorting plugs. For Gnd pin connections, I made up a few jumpers using three pin DuPont shells, two female crimp pins and a short piece of wire. After crimping the female pins to each end of the wire, I inserted them into the end slots of the three pin shell.

If you ever want to reconnect the trances that you cut, each one has a set of through holes. You can either solder a U shaped jumper wire in the holes or add a two pin header and use a standard two pin shorting plug to make a removable jumper.

A word of caution. The 3.3V regulator on the ESP32 dev kit is used to provide 3.3V for the ESP32 and any peripherals that you attach to the 3.3V bus. The regulator has a 1A limit. The higher the Vin voltage and the more current you draw will cause the regulator to heat up. Keep this in mind when trying to drive high current devices like LED strips or servo motors with 3.3V. A few I2C devices like gyros, accelerators and ADC convertors should not be a problem.

Step 3: Vin

Vin is the input voltage for the motors and the 5V regulator. Vin can be any voltage from 5V to 12V. If you are using 5V for Vin the output voltage of the on board 5V regulator will not be 5V. This is due to the 5V regulator must have a voltage higher than 5V to regulate to 5V.

The Vin is also used as the input voltage to the 3.3V regulator on the ESP32 dev kit.

The ESP dev kit reference design has a diode to isolate the USB voltage from the voltage on the Vin pin of the dev kit. The diode ensures that the Vin voltage does not try to drive the USB voltage and that the USB-to-Serial bridge chip on the ESP32 dev kit is only powered by the USB voltage. This means that you are safe to connect a voltage source higher than 5V to the Vin of the breakout board and use the USB connection at the same time, without fear of destroying anything. The voltage regulator on the ESP32 dev kit is in the same family as the voltage regulator used on the breakout board. This means that they can handle the same range of input voltages.

Connect the battery pack that drives the motors to the Vin terminals and it will also power the ESP32 and any peripherals that you have connected.

Step 4: HC-SR04 Sonar Sensors

Two four pin headers are provided for connection of the popular HC-SR04 Sonar sensor. The headers are located on opposite sides of the breakout board, near the motor screw terminal blocks. The headers are setup for one-to-one connection with the HC-SR04.

The HC-SR04 is a 5V device. It is powered by 5V and its output (Echo) signal is at 5V levels. The ESP32 has 3.3V GPIO and is not 5V tolerent. Therefore you need some kind of a voltage level converter to bring the 5V output of the HC-SR04 down to the 3.3V level of the ESP32. The breakout board has a simple voltage divider for each of the HC-SR04 Echo signals to perform the level conversion. No level conversion is required for an ESP32 GPIO pin to drive the Trig signal of the HC-SR04.

The four pin header for the HC-SR04 provides the 5V and Gnd connections for the sensor. The 5V is provided by the 5V regulator on the breakout board.

While a four pin header is provided to connect to the HC-SRO4, a two pin header is provided to connect the Echo and Trig signals of the HC-SR04 to the ESP32. This way you can chose which GPIO pins to use. Use female-to-female jumper wires to make the connections. T is the Trig input and E is the voltage level converted Echo output signal.

It should be possible to use the HC-SR04 header to connect some other 5V sensor. Connect the output of the 5V sensor to the Echo input and use the voltage divider to convert it to a 3.3V signal. The voltage divider will handle signals that have slow transitions. For high speed transitions you should use an active voltage level converter. If you connect an analog signal to the voltage divider and then to an analog input on the ESP32, you should take into account that the voltage swing will be zero to 3.3V, not zero to 5V when calculating the volts-per-count.

For example, you could wire a Vishay TSOP34838 IR sensor to the 5V, Gnd and Echo pins of the HC-SR04 header (Echo is wired to the output pin of the sensor). Then you should be able to receive IR commands from any IR remote that uses a 38KHz carrier.

Step 5: Tri-Color LED

The tri-color LED is a 5mm, common anode, through hole, RGB LED. Current limiting resistors are provided and the common anode is wired to the 3.3V bus. A three pin header labeled as RGB is provided for using the LED. A low level signal on one of the RGB pins will light up the LED with that color. Driving multiple RGB inputs at the same time will result in multiple LEDs lighting up with the resultant color mix. You can use female-to-female jumpers to connect the RGB header pins to the GPIO pins of your choice. If you wire the LED to a GPIO pin that has PWM capabilities then you can vary the brightness of the LED by varying the PWM low time. I like to use the LEDs to help me debug the code I am working on.

Step 6: I2C Breakout

The breakout board has four rows of header pins for the I2C interface. Two of the rows are four pins each and are 3.3V and Gnd. The other two rows are five pins each and are for SDA and SCL. The extra pin in each of these rows is so that you can uses two female-to-female jumper cables to connect the rows to the GPIO pins of your choice. The ESP32 can have the SDA and SCL signals on several of the GPIO pins. Up to four 3.3V, I2C devices can be connected and powered without resorting to daisy chaining cables. There are no pullup resistors on SDA and SCL signals on the breakout board. The pullup resistors should be on the devices that you attach to the I2C bus.

Note: For those who are unfamiliar with I2C, pullup resistors are required due to the SDA and SCL pins being open drain, tri-state, bi-directional pins. The value of the pullup resistors affects the slew rate and ringing on the bus.

Step 7: Bill of Materials

All resistors are SMT 1206.

All capacitors are SMT, case A, EIA 3216.

All headers and socket strips are 0.1 inch (2.54mm) pitch.

6 - twenty pin male headers

6 - five pin male headers

4 - four pin male headers

1 - three pin male header

2 - two pin male headers

2 - twenty pin female socket strips

1 - TB6612FNG board, comes with two, eight pin male headers

3 - 10uf Tantalum capacitors

1 - 10K resistor

2 - 2.2K resistors

5 - 1K resistors

1 - AMS1117, 5V

1 - 5mm, common anode RGB LED

3 - 3mm pitch, two pin, screw terminals

Optional

3 - two pin male headers - for reconnecting cut Vin, 3.3V and Gnd traces

Step 8: Wrapping It All Up

This is a very versatile ESP32 breakout board with the most common features required by simple robots built in to the breakout board.

The breakout board is not limited to ESP32 dev kits. Any microcontroller board that has dual rows of up to twenty pins on one inch spacing can be used. An ESP8266 or an LPC1768 board would fit. You can assemble the board without the TB6612FNG daughter board and use to breakout just the GPIO. The board gives you lots of options for how to use it.

If you have some of these boards made, do not remove the 'Macedon Engineering' name from the boards. You may freely use these boards for any non-commercial application. If you do make and use the board I would appreciate a shout out of what you used it for. I hope that you find the board useful.

PCB Contest

Participated in the
PCB Contest

Share

    Recommendations

    • Sensors Contest

      Sensors Contest
    • Backyard Contest

      Backyard Contest
    • Pets Challenge

      Pets Challenge

    Discussions