Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

Application in control system of intelligent

car based on ESP8266


Cite as: AIP Conference Proceedings 2185, 020030 (2019); https://doi.org/10.1063/1.5137874
Published Online: 09 December 2019

Hui Zhang, and Yani Fan

ARTICLES YOU MAY BE INTERESTED IN

Preface: 2019 5th International Conference on Green Power, Materials and Manufacturing
Technology and Applications (GPMMTA 2019)
AIP Conference Proceedings 2185, 010001 (2019); https://doi.org/10.1063/1.5137844

Tiny electronic component detection based on deep learning


AIP Conference Proceedings 2185, 020002 (2019); https://doi.org/10.1063/1.5137846

The application and prospects of bionic technology in hydraulic transmission field


AIP Conference Proceedings 2185, 020007 (2019); https://doi.org/10.1063/1.5137851

AIP Conference Proceedings 2185, 020030 (2019); https://doi.org/10.1063/1.5137874 2185, 020030

© 2019 Author(s).
Application in Control System of Intelligent Car Based on
ESP8266
Hui Zhang1, a), Yani Fan1, b)
1
Guangdong University of Education, Guangzhou 510303, China.
a)
Corresponding author email: zhanghui@gdei.edu.cn
b)
fanyani@gdei.edu.cn

Abstract. In order to realize remote control intelligent car by wireless network, STC89C52 is used as the main control
CPU, and wireless WIFI module ESP8266 is adopted. The system uses STC 89C52 as the development platform, sends
commands to ESP8266 through the serial port AT commands, configures the corresponding address and port number, sets
ESP8266 as TCP server and enables WIFI at the same time, connects ESP8266 to control the car through the APP. PWM
speed control function and adjusting the speed value of the car are analyzed through gravity sensor. The test results show
that the purpose of wireless remote control car posture has been realized, and the work is stable.

Key words: Remote Control Car; Single Chip Microcomputer; Wireless; ESP8266.

INTRODUCTION
Today, with the continuous development of robot technology, the production of smart cars is becoming more and
more popular. With the continuous update of technology, more and more new smart car designs are also emerging.
As for the control method of the car, the common remote control methods include infrared, Bluetooth and WIFI. With
the rapid development of information technology, WIFI has been regarded as a relatively basic living condition, and
it is everywhere in life. In recent years, Lexin Intelligent Internet Platform has launched a high-performance WIFI
module named ESP8266. Its powerful performance provides an effective and stable control method for design the
system. Therefore, this paper uses ESP8266 as the control module to realize the wireless remote control of the smart
car.

OVERALL SYSTEM DESIGN


The system adopts STC89C52 single-chip microcomputer as the core control chip, and uses ESP8266 module as
the data transmission channel. When the system is initializing, the main control chip sends the AT commands through
the serial port to configure ESP8266 module. After setting the corresponding parameters, the data is sent to the
ESP8266 module through the mobile phone software. The chip reacts differently based on the received data to control
the drive module of the motor. The overall design block diagram of the smart car system is shown in Fig.1.

2019 5th International Conference on Green Power, Materials and Manufacturing Technology and Applications (GPMMTA 2019)
AIP Conf. Proc. 2185, 020030-1–020030-7; https://doi.org/10.1063/1.5137874
Published by AIP Publishing. 978-0-7354-1932-2/$30.00

020030-1
FIGURE 1. Block diagram of the smart car system design

HARDWARE DESIGN

Drive Module L293D


L293D acts as motor drive chip, which is a dual-bridge driver chip. It can drive two DC motors or one stepper
motor at the same time. The output current can reach 600mA and the peak output current can reach 1.2A. The operation
is simple and the cost is accepted. The change of high level and low level is realized by programming, It is convenient
to realize the forward, backward, turning and other actions of the car. The connection method is shown as Fig.2. EN1
and EN2 represent the enable switches of two motors. IN stands for input and OUT stands for output.

FIGURE 2. Motor Drive Module L293D

WIFI Module
The chip of WIFI module is ESP8266. ESP8266 is a kind of Internet of Things chip which produced by Lexin
Company. It is an ultra-low power UART-WiFi transmission module with competitive package size. It is designed for
mobile devices and Internet applications, it connects users' physical devices to Wi-Fi, with stable performance and
low price [1-2]. The chip has been introduced in many different models so far. Because the circuit function of this
design is not complicated, the early ESP8266 chip can meet the design requirements. ESP8266-01 is selected for this
paper.

REALIZATION OF WIFI FUNCTION

Introduction to the Working Mode of ESP8266


There are three working modes as follows [3-5]:

020030-2
(1) STA mode: ESP8266 first connects to the network via a router, and then connects devices such as mobile
phones and computers to the same network and implements WIFI control function.
(2) AP mode: ESP8266 itself turns on WIFI. As a hot spot, devices such as mobile phones and computers can
directly connect to the hot spot of ESP8266 and transmit data to realize the control of the device.
(3) STA+AP mode: STA and AP modes coexist, and the mode can be quickly switched between the two modes
by controlling the module through the network.

Introduction to the Pin of ESP8266


VCC: 3.3V Power supply.
RST: Reset pin which can be used for external hardware reset.
CH_PD: Enable pin, must be connected to the high level.
TXD: Serial port transmission pin, which is connected to the serial data receiving port of the master chip.
RXD: Serial port receiving pin, which is connected to the serial data transmitting port of the master chip.
GPIO0: When GPIO is high level, the FLASH starts up. When GPIO0 is low level, system is upgrading. At this
time, the internal firmware can be upgraded through the serial port.
GPIO2: This pin leads an IO port for ESP8266.
GND: Ground.
The typical connection diagram of ESP8266 is shown Fig.3.

FIGURE 3. Hardware connection of ESP8266

AT Command Operation of ESP8266


ESP8266 supports a variety of Socket AT commands. It can easily configure various modes and parameters by
sending corresponding AT commands through serial port assistant [6-8]. The basic AT commands are shown in Table
1.

Serial Assistant Uses AT Command to Configure ESP8266


According to the instructions of ESP8266, the correct steps are as follows:
(1) Send AT to test if ESP8266 connection is OK.
(2) Send AT+CWMODE_DEF=2 to enter mode 2 SoftAP.
(3) Send AT+CIPMUX=1 and configure it in multi-connection mode
(4) Send AT+CIPSERVER=1,333, and configure the port number of the TCP server to be 333.
(5) Send AT+CIOBAUD=9600 and set baud rate to 9600bps.
Here is the configuration interface of the serial port assistant as Fig,4 shown.

020030-3
TABLE 1. Basic AT instructions
Command Function Return Value
Test command
AT OK
Restart command
AT+RST OK
AT version, SDK version, company, release
AT+GMR View version information
time
ATE0 Close echo
ATE OK
ATE1 Turn on echo
Set baud rate
AT+CIOBAUD OK
AT+CIOBAUD=<rate>
1.Station mode
OK
AT+CWMODE 2.AP mode
3.AP+Station mode
If the format is correct, returns:
OK

otherwise returns
single-way connection (+CIPMUX=0): +CME ERROR: invalid input value

AT+CIPSTART=<type>,<addr>,<port> Connection is successful, returns:


CONNECT OK (CPIMUX=0)
AT+CIPMUX
<id>, CONNECT OK (CIPMUX=1)
Multiple connections (+CIPMUX=1):
If the connection already exists, returns
AT+CIPSTART=<id>,<type>,<addr>,<port> ALREADY CONNECT

If the connection fails, returns:


CONNECT FAIL (CIPMUX=0)
<id>, CONNECT FAIL (CIPMUX=1)
AT+CIPSERVER Establish a TCP server and set the port OK

FIGURE 4. AT Command Configuration

020030-4
PROGRAM DESIGN

APP Design
The main function of the app is to send data to the serial port of the main control chip through the hotspot connected
to ESP8266. The main control chip performs the corresponding action after making the judgment according to the
received data. In order to ensure the correct data transmission between the upper computer and the lower computer,
the data transmission protocol shown in Table 2 is prepared (the format of the protocol data is hexadecimal). The
operation interface of the app is shown in Fig.5.

TABLE 2. Data Transfer Protocol


Function Frame Header 1 Frame Header 2 Judgment Value
Forward FE EF 0x01
Back FE EF 0x02
Turn left FE EF 0x03
Turn right FE EF 0x04
Stop FE EF 0x00

FIGURE 5. Software Interface of Mobile Phone

Program of Main Control


Serial Port Initialization and Baud Rate Setting

In order to make the main control chip normally communicates with ESP8266 and data transmission, the first thing
to do is to set the baud rate of the serial port of the main control chip, so that the baud rate of the main control chip is
consistent with that of the ESP8266. Specially, the default setting of ESP8266 is 115200bps, however the main control
chip used in this design is STC89C52, whose baud rate can not achieve such a high level, so the baud rate of the main
control chip and that of ESP8266 should be set to 9600bps. The following is the UART initialization procedure. The
program in this part is as follows
void UsartInit()
{
TMOD |= 0x20;// Serial port mode
RCAP2L=0xD9;// Set the baud rate to 9600bps
RCAP2H=0xFF;
T2CON=0x34;
SCON=0x50;
TH1 = 0xFD;
TL1 = TH1;
PCON = 0x00;

020030-5
EA = 1;// Turn on the total switch of interrupt
ES = 1;// Turn on the serial port interrupt switch
TR1 = 1;// Turn on timer1
}

Initialization of ESP8266

The operating mode and baud rate of ESP8266 are initialized by the AT commands as follows. The program in
this part is as follows
{
UsartInit(); // Serial port initialization
SendStr("AT+CWMODE_DEF=2\r\n");// ESP8266 enters mode 2 SoftAP
HAL_Delay(100);//delay 100ms
// SendStr("ATE0\r\n");// Turn off echo
// HAL_Delay(100);
SendStr("AT+CIPMUX=1\r\n");// Set ESP8266 to multi-connection mode
HAL_Delay(100);
SendStr("AT+CIPSERVER=1,333\r\n");// Configure ESP8266 as a TCP server and set the port number.
}

Data Receive

Before receiving the data, open the serial port and define an array for storing the received data. When the app is
connected to the ESP8266, the main control chip will continuously receive the data and store the data to the
corresponding array waiting for the master chip to process. The program in this part is as follows
void Receive_Array(uint8_t Data)
{
if(!receive_flag)
{
switch(Data)
{
case 0xFE: // Determine if it is a frame header
{
if(receiveData<254)index++;
Receive_Array[dat]=Data;
}break;

case 0xEF: // Determine if it is the end of the frame


{
Receive_Array[dat]=Data;
if(receiveData>1)
{
dat=1;
receiveData=1;
FEEF=1;
}
else if((receiveData>0)&&(!FEEF))
{
dat=1;
receiveData=1;
FEEF=1;
}
}break;

default:

020030-6
{
if(!FEEF){receiveData=0;}
else{receiveData=1;}
Data_Array[dat]=Data;
}break;
}
dat++;
if(!FEEF){dat=0;}
if(dat>3){receive_flag=1; dat=0; FEEF=0;} }
}

PWM Function

The main function of the PWM button equipped on the app is to adjust different PWM values and send the value
to the main control chip through ESP8266. The master chip continuously reads the current received PWM value
through a timer and compares the value with the previous PWM value. When the newly received PWM value is
different from the previous value, the speed of the car is changed. The program in this part is as follows
If (Receive_Array[3]!=PWM_Last)//ESP8266 update the data if the value passed is different from the previous
value {
PWM_Last=Data_Array[3];
PWM=56320+92*Data_Array[3];// PWM speed regulation
}

CONCLUSIONS
This paper is based on a popular wireless communication module named ESP8266, the main function is to wireless
remote control the smart car through the app, and to realize real-time PWM speed control of the car through the APP.
The program mainly judges the data received by the serial port, and formulates the relevant data transmission protocol
to ensure the correct data transmission. It is worth noting that the communication baud rate setting between the main
control chip and the ESP8266. The circuit design is simple, there are no complicated line connections. The program
is also relatively simple, and the stable ESP8266 can well realize the function of the WIFI remote control.

REFERENCES
1. García-Orellana Carlos J,Macías- Macías Miguel, González-Velasco Horacio M, García- Manso Antonio,
Gallardo-Caballero Ramón. Low-Power and Low-Cost Environmental IoT Electronic Nose Using Initial Action
Period Measurements. [J]. Sensors (Basel, Switzerland), 2019, 19 (14).
2. Monika Kashyap, Vidushi Sharma, Neeti Gupta. Taking MQTT and NodeMcu to IOT: Communication in
Internet of Things [J]. Procedia Computer Science, 2018, 132.
3. Fan Yang. Research and Application of Control Algorithm Based on Intelligent Vehicle [J]. Procedia Computer
Science, 2019, 154.
4. Giacomo Innocenti, Roberto Genesio, Alberto Tesi. An Approach to Robust Control of the Hopf Bifurcation [J].
Journal of Applied Mathematics, 2011, 2011.
5. Zhi Li. Design of Intelligent Inspection Car based on STM32 [P]. Proceedings of the 3rd International
Conference on Computer Engineering, Information Science & Application Technology (ICCIA 2019), 2019.
6. García-Orellana Carlos J,Macías-Macías Miguel, González-Velasco Horacio M, García- Manso
Antonio,Gallardo-Caballero Ramón. Low-Power and Low-Cost Environmental IoT Electronic Nose Using
Initial Action Period Measurements. [J]. Sensors (Basel, Switzerland), 2019, 19 (14).
7. Palagani Yellappa,Mohanarangam Krithikaa,Shim Jae Hoon,Choi Jun Rim. Wireless power transfer analysis of
circular and spherical coils under misalignment conditions for biomedical implants. [J]. Biosensors &
bioelectronics, 2019, 141.
8. Talysson M.O. Santos,Márcio F.S. Barroso, Rodrigo A. Ricco, Erivelton G. Nepomuceno, Érika L.F.C.
Alvarenga,Álvaro C.O. Penoni,Ana F. Santos. A low-cost wireless system of inertial sensors to postural analysis
during human movement [J]. Measurement, 2019, 148.

020030-7

You might also like