Introduction: Line Following - Obstacle Avoiding - Drawing Robot (ESP8266 Dual DC Motor Controller Board)

About: Maker 101; Beginner and intermediate level Maker projects! You can find projects such as "How to" and "DIY" on programmable boards such as Arduino, ESP8266, ESP32 and Raspberry Pi on this channel. The projects…

Hi everyone! In this project, I designed a board that includes the ESP8266 (ESP-12F) WiFi module, allowing you to control sensors such as HC-SR04 ultrasonic and infrared (IR), a servo and dual DC motors (DRV8848). To test the development board, we're going to build a small but fun 3D robot and control it, let's get started!

Supplies

Step 1: 3D Parts of the Robot Chassis

Followers will remember, I previously designed a board based on Atmega328 with L293D motor driver and used a 3D robot chassis. I will use the same chassis in this project, but the parts of the chassis are very deformed, so I used PCBWay's 3D printing service when ordering the printed circuit board.

One of the best things about PCBWay is that it provides many services such as PCB, stencil, 3D and CNC that you need while doing a project. The new 3D parts were produced with SLA printing. A type of resin material is used thus providing dimensional accuracy, smooth surface and excellent detail. The previous 3D parts are FDM printing. PLA material is used for low-cost, non-functional prototyping. You can see the difference in quality between the parts when the models are compared.

Before we move on to the printed circuit board, let's paint the 3D parts black with acrylic spray paint. Thus, there will be color harmony with other additional 3D parts of the robot. For this you will need a box and water-based acrylic paint. We place the 3D parts to be painted in the box and apply the spray paint as a thin layer on the part surfaces.

Step 2: Printed Circuit Board - ESP-12F DRV8848 Driver Board

Until the 3D parts are dry, let's take a closer look at the printed circuit board. Printed circuit boards are preferred for long-term use, stable and more durable electronic circuit prototypes. I prefer PCBWay to turn my circuit designs into durable prototypes. If you want to have these PCBs with low-price and high-quality, you can visit the shared link.

https://www.pcbway.com/project/shareproject/ESP_12F_DRV88xx_Motor_Driver_Development_Board.html

Some "surface mount device" components are preferred in this board, this affects the size and cost of the board design. For the assembly of SMD components, a stencil is generally preferred. Solder stencils help to accurately apply solder paste in position of components and the stencil is usually ordered with the printed circuit board. 

Step 3: The Process of Applying Solder Paste Using a Stencil

Solder stencils help to accurately apply solder paste in position of components. The process of applying solder paste using a stencil is simple, first fix the printed circuit board and place the stencil to match the board. Then put some solder paste on the stencil with the help of a spoon and spread it with a spatula. 

Here are some materials you need for this step:

  • Solder Paste
  • Masking Tape
  • Solder Paste Spreader

Step 4: Placement of Components on PCB and Soldering Process

After applying the solder paste, it is necessary to place the required components on the board. Where to place these components is usually indicated by a designator or footprint reference. These references are used as part of the PCB design and ensure the correct placement of components. Designator shows what a component is and where it is located.

After the components are placed on the solder pads with the help of solder paste, the soldering process begins. Soldering is usually done with a hot plate machine or a hand soldering iron. The soldering machine heats and melts the solder paste and fixes the components in place. After the soldering is complete, the components are completely fixed in place when the solder paste has cooled. 

After soldering a few more components, the board will be complete. These components are a few headers and resistor. It can be easily soldered with a soldering iron.

Here are some electronics tools you need for this step:

The required components are listed in the attached Partlist.txt file.

Step 5: Assembly of 3D Parts for the Robot Chassis

The assembly of the board is complete, now let's move on to the assembly of the 3D parts. After the paint process, you can better see how smooth the surface of the 3D parts is. When we compare FDM parts and SLA parts, you can see the difference in print quality more clearly.

As for the assembly part, we need bolts, nuts and washers for the free spinning wheels. The nuts loosen while the wheels are turning, so I found a solution by using some threadlocker. Surely there are people who use different methods. The link to the page where the 3D parts are shared is in the video description, you can take a closer look.

I chose two 600 RPM 6 volts Gear DC Motors, you can use different motor options here. But remember, the motors are fed with 5 volts through the regulator. I used some hot glue to attach the motors, it may not actually be needed but in case of vibration the motors may come off. 

We need 32 tracks in total. 16 tracks are required for each side of the robot. Thread the tracks together and connect them using a piece of filament. Attach the master wheels to the motor shaft and then place the tracks on each side of the robot and fix it one more time with the help of filament.

Step 6: First Programming "Blink"

I made the first connection via micro USB and the board power indicators look fine, it also provides USB communication. Now let's try to upload a "Blink" sample code and check that the ESP8266 is working properly. The "Blink" code sample is included with the ESP8266 WiFi setup and it is listed in "Examples". Then select the board and port and press upload. When you see the "Connecting..." message, press the reset and boot buttons at the same time, then release the reset and then the boot button respectively. The code will upload in a few seconds. As you can see, the board is communicating and executing the code without any problems. I also tested the same code via the USB to TTL converter and the board still worked without any problems. 

Step 7: Dual Motor Drive Test - DRV8848

At this stage, let's upload code to test the motor driver and DC motors of the board. This sample code contains basic functions to control dual DC motors in all directions. After defining the pins to which the motors are connected and the data such as the rotation speed of the motors, the motor direction functions are created and the functions are executed with the defined delay in the loop. As you can see, the LED indicators connected to the directions of the motors on the board are working correctly. 

Let's connect the battery and motors and attach the board to the robot chassis and make sure that the motors are working correctly.

Step 8: Obstacle Avoiding Robot - HC-SR04 Sensor

Let's connect the HC-SR04 ultrasonic sensor and then upload the robot code that changes direction when it encounters an obstacle, that is, avoids the obstacle. In this code sketch, the pins to which the motor and the sensor are connected are defined. Pin modes are specified in the "Setup" section. Some calculations were entered for the ultrasonic sensor in the "Loop" section and then the motors were moved forward if there were no obstacles up to the specified distance. If an obstacle is detected, with some delay command, the motors will stop, then move backward, stop again and avoid the obstacle by turning. 

Step 9: Line Following Robot - Infrared (IR) Sensor

In this section, let's connect the infrared sensor module to our robot and test it. The Infrared sensor module used is a model that can be easily found in the markets and there are many resources about its use. If you look at the infrared code sketch, you will notice that it is simpler and shorter than the previous codes. I tried to write each code differently from each other, so that you can better understand each function in the codes by comparing them with other codes. The simple logic in this code is when the infrared sensor detects it will be "HIGH" and the robot will move forward. When the sensor is "LOW", the robot will turn to the left and try to reach the "HIGH" position again. So when it finds the black line, the robot will continue its forward movement.

Step 10: Drawing Robot - Servo Motor

In the last part, let's test a servo motor control with the board. Thus, we will have completed the test of the board to run all the other components together with the motors at the same time. For this, we will run a simple code sketch, we connect a pen to a servo motor, the servo motor will go down and the robot will spin around itself, then the robot will stop and the servo motor will go up. Of course, you can develop different scenarios, it's all up to your imagination! Thanks for reading, don't forget to following!