#Test: Shield Motor I2C Wemos D1 Mini (or Pro) to drive 2 motors 15Vdc

Today, I propose to discover the Shield Motor I2C for Wemos D1 Mini. This small shield built around the Toshiba TB6612FNG driver allows to control 2 DC motors. The board is capable of independently controlling the speed and direction of each motor (A, B). The maximum permissible power is 1.2A per motor. It supports a power peak at 3.2A. By default, the card is located at address 0x30 on the I2C bus. The card comes with a library in C ++ as well as 4 examples of Arduino code. The firmware of the STM32F030 to control the shield via the I2C bus is not installed (or properly installed) on some clones. It is best to buy the Shield Motor directly on the official Wemos store on Aliexpress. In addition the card does not cost more.

Unpacking the Shield Motor I2C TB6612FNG for Wemos D1 mini

The Shield Motor I2C comes in an anti-static pouch with a simple connector set. It is therefore planned to close the Shields stack. This is quite logical considering the wiring to be made.

wemos d1 mini shield motor deballage

Communication with the card is via the I2C bus. By default, pins D1 and D2 are used. The official page of the map can be found here.

The Shield is built around Toshiba’s TB6612FNG circuit. The complete technical data sheet can be found here.

 wemos d1 mini motor i2c shield TB6621FNG

Technical characteristics

  • I2C interface (see next paragraph to change the default address 0x30)
  • Maximum supply voltage (VM pin): 15Vdc max
  • Output current (pin Iout): 1.2A (average) – 3.2A (in peak)
  • Standby function for energy saving
  • CW / CCW / short brake / stop motor control modes
  • Pins
    • VM: Power supply + (max 15Vdc)
    • GND: negative motor terminal –
    • A1 A2: Engine A
    • B1 B2: Motor B
    • S: standby control
    • Standby control
      • I2C mode: Controls the standby function of the TB6612FNG circuit using the I2C protocol
      • IO mode: Controls the standby function of the TB6612FNG circuit with the “S”
    • Reset modes
      • Welded: reset with the d1 mini (reset at power up or by pressing the Reset button on the wemos d1 mini). This is the default mode.
      • Opened: reset by the pin marked “DTR”

How to change the I2C address of the card

By default, the Shield is at the address 0x30 on the I2C bus. On the back of the card there are 2 jumper AD0 and AD1. By making a bridge by welding the two terminals of each jumper, one can change the address of the shield. The ‘-‘ means that the pot is open. The ‘x’ means that the bridge is closed by a weld.

AD1 AD0 Adresse
x 0x2E
x 0X2F
x x 0x30 (défaut)

Welding of connectors

There are 4 connectors to be welded on the Shield Motor. One on each side that allows to stack the shield on the Wemos D1 Mini as usual. The third (USB side) is used to power the motor on an external battery (the Wemos is not powerful enough to power engines) and to drive for both engines. The fourth connector opposite the motor connector is not documented. It seems that this is simply a serial port. Hackers can use it to reprogram the STM32F030 microcontroller used for I2C communication (full tutorial). The DTR pin allows you to reset the TB6612FNG. The jumper RST on the back of the board will have to be de-soldered to activate this mode. To weld the motor connector, I advise you to insert it on a breadboard to keep the shield vertical during welding.

wemos d1 mini shield motor soudure connecteur moteur mise en place wemos d1 mini shield motor soudure connecteur moteur soude

Arduino / ESP8266 Code

Wemos has developed a C ++ library for Arduino. The source code as well as four basic examples are available on GitHub here:

  • Motor_base
  • Motor_base2
  • Motor_standby_i2c
  • Motor_standby_io

To call the library in your Arduino programs, it will suffice to declare it at the beginning of the program

#include "WEMOS_Motor.h"

The Motor method is used to initialize an object for each motor A and B. The Motor class takes as parameter:

  • The I2C address of the card. Default 0x30
  • Use the _MOTOR_A or _MOTOR_B key to indicate which engine the object is associated with
  • The PWM frequency. By default, it is 1000Hz.
  • Standby mode. By default, it is managed by the shield. If you need to control it from the Wemos, specify the pin used. Do not forget to weld the STBY bridge to the back of the card.

This gives, for example, for the motor A

Motor M1(0x30,_MOTOR_A, 1000);

To control the engine, we have the setmotor method which takes 1 or 2 parameters. The first parameter is the order to be executed. The second is the setpoint of the parameter. The commands offered by Toshiba’s integrated circuit TB6612FNG include the following:

  • _SHORT_BRAKE. An early explanation of the interest of the function here
  • _CCW which means counter clockwise or counterclockwise rotation. A power level between 0% and 100% is set as a parameter, which also corresponds to the maximum speed of the motor
  • _CW which means counter wise or clockwise rotation
  • _STOP, no need for explanation
  • _STANDBY, allows you to pause the motor.

You understand, there is nothing very complicated in the use of this bookstore. As usual, we get a very compact assembly and very easy to integrate in our projects. We will see in an upcoming tutorial how to use it to recycle an old remote-controlled car. This shield, which costs less than €3 (excluding postage), will be easier to use than an L293D H-bridge.

Subscribe to the weekly newsletter

No spam and no other use will be made of your email. You can unsubscribe anytime.


1 Comment
  1. Hello Craig. It’s too bad ! Indeed the copy protection was activated by default on a plugin. It is resolved. You have to understand that unfortunately many blogs are unscrupulous with the work of others! See you soon i hope

Leave a Reply

DIY Projects
%d bloggers like this: