Home | Difficulty level | Advanced | Recycle a remote-controlled car (RC car) with an ESP8266, Shield Motor Wemos d1 mini and Blynk

Recycle a remote-controlled car (RC car) with an ESP8266, Shield Motor Wemos d1 mini and Blynk

For this new project, I propose to recycle a remote-controlled car by replacing the radio receiver by an ESP8266. The engines will be controlled using a shield Motor for Wemos d1 mini presented in this article. You definitely have an old remote-controlled car that hangs at home. The remote control no longer works or has been lost. For this project, we will remove the printed circuit board containing the receiver and the motors. We will keep only the engines and battery pack that will be used to power the 2 engines. For this tutorial, I used a remote-controlled car model equipped with a motor for the orientation of the front wheels. The remote will be replaced with a tablet or a smartphone using the application and the Blynk library. If you do not have an old remote-controlled car, we will adapt the program in an upcoming tutorial for an RC Car kit.

Equipment used

For this project, I propose you to use the shield Motor for Wemos d1 mini. It comes stacked on the ESP8266 which allows a very compact mounting. The motors will be powered using the old battery pack. The Wemos will be powered by a LiPo battery. Here I used a 1100mAh battery. I advise you to use the shield battery (shown here) or use a Power Bank.

esp8266 Wemos D1 mini Wemos D1 Mini
wemos d1 mini motor shield i2c I2C 2 motors Driver (15 VDC max.)

about €2,85 (exclude postage)

batterie lipo 150mah 3V7 LiPo 3,7V battery for Wemos d1 mini

from €6,90

Since it is a remote-controlled car project, there are necessarily options :-).

wemos d1 mini shield batterie lipo LiPo battery charger with micro USB connector

about €2,20€

JST XH2-2.54mm cable

about 0,23€

wemos d1 mini dual base Double base

about €0,95

kit connecteur header dupont jumper jumper Dupont connectors

about 4,17€ (x310)

Power Bank.

about €12

Warning. The firmware is not properly installed on many clones. I advise you to buy directly this shield on the official Wemos CC shop here.

Why not use an H-bridge in L293D?

Indeed, if you do not want to invest in a shield motor, it is quite possible to use an H-bridge, for example the L293D. The cost price is equivalent. On the other hand at the level of the implementation, it has nothing to do! On the shield motor, you will only have 6 wires to connect. The power supply from the battery pack and 2 wires per motor. You will not even need jumpers. You can recycle old threads (if they are long enough obviously). Lastly, the shield motor is already correctly wired to deliver all the power to the motor.

On an L293D, it will be necessary to connect a complementary power supply (eg a 4.5V battery) on pin 8 (VCC2) to deliver enough power to the motors. The Wemos d1 mini does not deliver enough power to operate the motors properly. Pin 16 is only used to power the H-bridge. You can connect it to the 5V output of the Wemos. Finally, do not forget to connect the ground of the battery to the ground of the Wemos.

L293D pinout repérage des broche
L293D pinout

 

Pin N°
 Function
 Nom
1
Enable pin for Motor 1. Actif High state
Enable 1,2
2
Input 1 for Motor 1
Input 1
3
Output 1 for Motor 1
Output 1
4
Ground (0V)
Ground
5
Ground (0V)
Ground
6
Output 2 for Motor 1
Output 2
7
Input 2 for Motor 1
Input 2
8
Motors Power supply from 9 to 12V (up to 36V)
 Vcc 2
9
Enable pin for Motor 1. Actif High state
Enable 3,4
10
Input 1 for Moteur 2
Input 3
11
Output 1 for Moteur 2
Output 3
12
Ground (0V)
Ground
13
Ground (0V)
Ground
14
Output 2 for Motor 1
Output 4
15
Input 2 for Motor 1
Input 4
16
Power supply 5V for L293H (up to 36V)
Vcc 1

Preparing the remote-controlled car

The first thing to do is to disassemble the old circuit. The most difficult is the disassembly. In my case, the body was glued to the chassis. Cut all cables as close as possible to the radio receiver.

rc car voiture telecommandee carte radio commande

Think about the planet. Do not throw away the old circuit. Recycle it in a waste disposal facility near you

Circuit

To connect the old cables to the shield motor, you can use a Dupont connector kit. Here is the finished assembly.

I used a double base to limit the height of the assembly. There is no particular position to respect. The Wemos d1 mini can be placed on the right or on the left. The Shield Motor does not come with connectors to stack, it took place above the Wemos. The shield battery on the free slot with LED. A green LED 5mm in diameter that can withstand a supply voltage between 3 and 3.4V, it is not necessary to reduce the voltage delivered by the Wemos d1 mini (3.3V).

Project Blynk

Launch Blynk on your smartphone or tablet. If you have a local server, connect to it by changing the source as shown in the screenshot below.

To get started with the Blynk application, follow this tutorial.

blynk create account local server

Create a new project. In the Device list, select ESP8266. In the Connection Type list, choose WiFi.

 esp8266 blynk rc car voiture telecommandee shield motor

Then place 4 buttons. Choose push mode. The value is maintained until it is released. Here are the virtual variables used in the Arduino code:

  • V1: advance
  • V2: backwards
  • V3: right
  • V4: left

esp8266 blynk rc car voiture telecommandee shield motor bouton avance

Finally place a slider (V0). Check Send values on release only, which allows the value of the setpoint to be sent only when the slider is released. The maximum limit must not exceed 100 (%).

esp8266 blynk rc car voiture telecommandee shield motor slider speed

Here is the project obtained

esp8266 blynk rc car voiture telecommandee shield motor

Arduino Code / ESP8266

For this project, we will include the following 3 libraries:

The following variables are used to define

  • The setpoint of the power of the propulsion engine
  • The pin on which is connected the LED that indicates the connection status to the Blynk server
  • WiFi network connection settings
  • The token of the Blynk project
Now we will create two objects that control the engines
In the setup loop, the Led output is initialized and the connection to the local Blynk server is initiated. If you are not using a local Blynk server, simply delete the last two parameters (IP from the local Blynk server and port).
The loop loop is very simple. We simply call each pass Blynk. We check that we are always connected to the Blynk server. If this is the case, the Led is switched on. Otherwise, it is turned off.
Now all you have to do is manage the control commands:

  • V0: adjusts the motor power between 0 and 100%
  • V1: advance
  • V2: backwards
  • V3: Turn left
  • V4: turn right

For example, to move forward, we use the setmotor method, which takes two parameters

  • One command : _CW, _CCW, _SHORT_BRAKE, _STOP or _STANDBY
  • A value

So here, to move forward, we will pass the _CW parameters with the setpoint contained in the variable _speed. To reverse, the reverse order will be passed, _CCW. If the commands are reversed, you can simply reverse the wiring at the shield motor. You will notice in the complete code that I have limited the reverse speed to 50% of the feedrate. Free to each to remove this limitation.

To go right or left, it is exactly the same. The motor will be rotated in one direction or in order. The steering wheels return to the center position with a spring. There is nothing to program. On the other hand it is an all or nothing operation.

Here is the complete code of the project. You still have to modify the parameters presented above before uploading the program on the ESP8266 of the Wemos d1 mini.

All that remains is to test the project. After each upload of the program into the ESP8266, it is necessary to make a reset of the card so that the shield Motor works. I do not know the origin of the problem yet. Wait a few seconds, the ESP8266 connects to the WiFi network and the Blynk server. If you are connected to a local server, the connection time should be faster.

  • Shafiqur Khan

    There seems to be a minor mistake in the wiring diagram for motor B. I think it should connect to B1, B2.

    Also, I’ve connected the shield with the Wemos D1 mini. Checked all the connections to see if the power supplies are sending power. However, for some reason my motor pins (A1, A2, B1, B2) are not getting power. VM and GND is hooked up to a 5V power source, and d1 mini is connected to USB. If I short VM/GND to A1/A2 or B1/B2, the motors are reacting as expected. How do I troubleshoot this?

    • Hello. Thank you very much. We can invert B1 and B2 and change in the program. The wemos does not deliver enough power (only 800mA) on the 5V output to power the motors. You must use a LiPO battery or even better the old batteries of the car. Have fun 🙂

      • Shafiqur Khan

        Looks like my motor shield came without a driver. So I flashed it. Then I stacked the wemos motor shield on top of the wemos d1 mini. Connected VM/GND of the wemos motor shield to a 5V (4×1.2V AA) source, and wemos d1 mini to a 3.7v LiPo battery, A1/A2 to motor 1 leads, and B/B2 to motor 2 leads. Am I missing anything? For some reason A1, A2, B1, B2 aren’t being powered up when I send command through the arduino sketch. However, the motors do react when I short A1/A2, B1/B2 to VM/GND.

        • Absolutely Shafiqur. I encountered exactly the same problem. As I mentioned in the article, it is absolutely necessary to buy the motor shield at wemos directly (http://s.click.aliexpress.com/e/f2Nr3jU). The clones do not work (well the ones I bought 🙁 !)