Professional Documents
Culture Documents
Application in Control System of Intelligent Car Based On ESP8266
Application in Control System of Intelligent Car Based On ESP8266
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
© 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.
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
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.
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.
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
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.
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;
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